The Challenge of Multilingual WordPress Sites
Managing a WordPress site in Arabic offers great accessibility to Arabic-speaking audiences, but it can create challenges when working with page builders like Divi. Many developers and site administrators prefer to use the Divi Builder interface in English, even while maintaining an Arabic frontend for their visitors.
This common scenario creates a unique challenge: How do you keep your WordPress admin and Divi Builder in English while your site remains in Arabic for your visitors?
The Solution: Custom Code to Force Divi Builder to English
After testing several approaches, I’ve found a reliable solution that forces the Divi Builder interface to display in English while keeping your frontend in Arabic. This code snippet targets the issue at a fundamental level by manipulating WordPress text domains and locale settings.
The Code Solution
Add this code to your child theme’s functions.php file or in a custom functionality plugin:
/**
* Force Divi Builder UI to English while keeping frontend in Arabic
*/
function force_divi_builder_to_english() {
// Only run in admin or Divi builder contexts
if (!is_admin() && !isset($_GET['et_fb'])) {
return;
}
// Define all Divi-related text domains
$divi_domains = array('Divi', 'et_builder', 'et-core', 'divi-builder');
// For each Divi text domain, override the translation loading
foreach ($divi_domains as $domain) {
// Unregister any existing translations
global $l10n;
if (isset($l10n[$domain])) {
unset($l10n[$domain]);
}
// Register an empty translations instance
$empty_mo = new MO();
load_textdomain($domain, false);
$GLOBALS['l10n'][$domain] = &$empty_mo;
}
// Set admin language to English specifically for logged-in users
if (is_user_logged_in()) {
update_user_meta(get_current_user_id(), 'locale', 'en_US');
}
}
// Run early, before text domains are loaded
add_action('init', 'force_divi_builder_to_english', 0);
// Additional hook to ensure the builder interface stays in English
add_filter('determine_locale', function($locale) {
// Only modify locale in admin or builder contexts
if (is_admin() || isset($_GET['et_fb']) || isset($_GET['et_pb_preview'])) {
return 'en_US';
}
return $locale;
}, 999);
How This Solution Works
This elegant solution addresses the language issue through several mechanisms:
- Targeted Context Detection: The code only activates in admin areas or when using the Divi visual builder.
- Text Domain Manipulation: It specifically targets all Divi-related text domains, preventing them from loading Arabic translations.
- Empty Translation Objects: By creating empty translation objects, it forces Divi to fall back to its default English text.
- User Locale Override: Sets the logged-in user’s admin locale preference to English.
- High Priority Locale Filter: Uses a high priority (999) filter to ensure our locale setting overrides any other plugins or theme settings.
Benefits of This Approach
- Non-invasive: Doesn’t modify any core WordPress or Divi files
- Selective: Only affects the admin and builder areas, leaving your frontend in Arabic
- Comprehensive: Handles all Divi-related text domains
- Admin-specific: Changes only affect logged-in administrators
- No plugins required: Eliminates the need for additional plugins that might cause conflicts
Implementation Instructions
- Access your child theme’s
functions.phpfile (or create a custom plugin) - Copy the code snippet above and paste it into your file
- Save the changes
- Refresh your WordPress admin and Divi Builder
Troubleshooting
If you’re still experiencing issues after implementing this solution:
- Make sure you’re using a child theme (never modify the parent theme directly)
- Check for conflicts with other language or translation plugins
- Verify that your user account has the correct permissions
- Clear your browser cache and WordPress cache
- Try deactivating other plugins temporarily to identify potential conflicts
Conclusion
Working with multilingual WordPress sites presents unique challenges, especially when using sophisticated builders like Divi. This code solution provides a clean, effective way to maintain an English interface for Divi Builder while preserving your Arabic frontend for visitors.
By implementing this approach, you get the best of both worlds: a familiar English editing experience and a properly localized website for your Arabic-speaking audience.
Have you faced similar challenges with other WordPress page builders? Share your experiences in the comments below!