WSForm Multilingual
WSForm Polylang Multilingual - AI-Generated Translation Management Plugin for WordPress
by Sebastian Berger · github.com/defcon1702/wsform-ml · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/defcon1702/wsform-ml/archive/refs/heads/main.zipAutomatic translation management for WSForm with Polylang integration.
⚠️ Important Notice
This plugin was entirely developed using AI (Cascade/Claude).
- ✅ Testing environment required: Only test on staging environments before production use
- ✅ Code review recommended: Code should be reviewed by a developer before production deployment
- ✅ Create backups: Always create a complete backup of your WordPress installation before installing
- ✅ Staging environment: Ideally test thoroughly on a staging environment first
Use at your own risk!
Features
✅ Auto-Discovery - Automatic scanning of all form fields ✅ Complex Forms - Support for Repeater, Conditional Logic, Select options ✅ Centralized Management - Database-based translation management ✅ Polylang Integration - Seamless integration with Polylang ✅ Warning System - Automatic detection of missing translations ✅ Backend UI - Intuitive admin interface ✅ Performance - Caching system for optimal performance
Installation
- Upload plugin to
/wp-content/plugins/wsform-ml/ - Activate plugin in WordPress
- Ensure WS Form is installed
- Optional: Install Polylang for multi-language support
Usage
1. Scan Form
- Navigate to WSForm ML in WordPress Admin
- Select a form from the list
- Click "Scan Form"
- The system automatically detects all translatable fields
2. Add Translations
- Select a language from the tabs
- Expand fields to see properties
- Enter translations
- Click "Save"
3. Frontend Rendering
The plugin automatically translates forms based on the current language:
- Uses
ws_form_pre_renderhook - Loads translations from database
- Applies translations before rendering
Supported Field Types
Basic Fields
- Text, Email, Textarea
- Number, Tel, URL
- Hidden, Password
Advanced Fields
- Select, Radio, Checkbox - Including options
- Repeater - Nested fields
- HTML/Text Editor - Rich content
- Conditional Logic - Conditional texts
Translatable Properties
label- Field labelplaceholder- Placeholder texthelp- Help textinvalid_feedback- Error messageoptions- Select/Radio/Checkbox optionshtml- HTML contentaria_label- Accessibility
Database Schema
wsform_ml_translations
Stores all translations with:
- Form ID, Field ID, Field Path
- Property Type (label, placeholder, etc.)
- Language Code
- Original & Translated Value
- Sync Status
wsform_ml_field_cache
Cache for scanned fields:
- Field structure
- Translatable properties
- Repeater hierarchy
- Last scan time
wsform_ml_scan_log
Log of all scans:
- Found/New/Updated fields
- Scan duration
- Error logs
REST API Endpoints
🔒 Security: All endpoints require manage_options capability (WordPress Admin only). Not accessible from outside.
GET /wp-json/wsform-ml/v1/forms
GET /wp-json/wsform-ml/v1/forms/{id}/fields
GET /wp-json/wsform-ml/v1/forms/{id}/translations
GET /wp-json/wsform-ml/v1/forms/{id}/translations/missing
GET /wp-json/wsform-ml/v1/forms/{id}/stats
POST /wp-json/wsform-ml/v1/forms/{id}/scan
POST /wp-json/wsform-ml/v1/translations
POST /wp-json/wsform-ml/v1/translations/bulk
DELETE /wp-json/wsform-ml/v1/translations/{id}
Hooks & Filter
Actions
// After successful scan
do_action('wsform_ml_after_scan', $form_id, $stats);
// After saving a translation
do_action('wsform_ml_translation_saved', $translation_id, $data);
Filter
// Customize translatable properties
apply_filters('wsform_ml_translatable_properties', $properties, $field);
// Customize translation map before rendering
apply_filters('wsform_ml_translation_map', $map, $form_id, $language);
Performance
- Caching: Scanned fields are cached (5-minute transient cache for forms list)
- Auto-Save: Debounced auto-save (500ms) with visual indicators
- N+1 Query Fix: All translations loaded in single query
- Batch Operations: Bulk-save for multiple translations
- Optimized Queries: Indexed database queries
- Lazy Loading: Translations loaded only when needed
Polylang Integration
The plugin uses Polylang functions:
// Detect current language
pll_current_language()
// Default language
pll_default_language()
// Available languages
pll_languages_list()
Also works without Polylang (fallback to English).
Development
Structure
wsform-ml/
├── wsform-ml.php (Main Plugin)
├── includes/ (Core Classes)
│ ├── class-database.php
│ ├── class-field-scanner.php
│ ├── class-translation-manager.php
│ ├── class-renderer.php
│ └── class-polylang-integration.php
├── admin/ (Backend)
│ ├── class-admin-menu.php
│ ├── class-rest-api.php
│ ├── assets/
│ └── views/
└── languages/ (i18n)
Adding Custom Fields
add_filter('wsform_ml_translatable_properties', function($properties, $field) {
if ($field->type === 'custom_field') {
$properties[] = [
'type' => 'custom_property',
'path' => 'meta.custom_property',
'value' => $field->meta->custom_property
];
}
return $properties;
}, 10, 2);
Requirements
- WordPress 5.8+
- PHP 7.4+
- WS Form (any version)
- Optional: Polylang
Support
For questions or issues:
- GitHub Issues
- WordPress Support Forum
License
GPL v2 or later
Changelog
See CHANGELOG.md for full version history.
1.7.0 (Latest)
- Auto-Save with Debouncing (500ms)
- Transient Cache for Forms List (5 min)
- Plugin Internationalization (de_DE, en_US)
- Visual Save Indicators
- Performance Optimizations
1.6.3
- HTML Field Support
- Numeric Field Sorting
1.0.0
- Initial Release
- Auto-Discovery for all field types
- Polylang Integration
- Backend UI
- REST API
- Warning system for missing translations