Translation Issue with Redux Framework – Custom Text Domain
-
Hello Redux Framework Support Team,
I’m facing a challenging issue with translations in Redux Framework while developing my theme (Liberty). My theme’s primary text domain is
liberty
, which works perfectly for all theme translations. However, for the Redux settings panel, I’ve implemented a separate text domain (liberty-settings
) to avoid conflicts and allow more flexibility. Unfortunately, Redux fails to apply translations for its sections, fields, and a test string in$args['footer_credit']
, despite the translations being correctly set up in theliberty-settings-fa_IR.po
file. Below is a detailed breakdown of the issue and the steps I’ve taken to resolve it. Environment- WordPress Version: 6.8
- Redux Framework Version: Latest (as of April 2025)
- Theme: Liberty
- Primary Theme Text Domain:
liberty
- Redux Settings Text Domain:
liberty-settings
- Translation File Location:
wp-content/themes/liberty/languages/liberty-settings-fa_IR.mo
(for Persian translations)
Problem
Translations for the theme’s primary text domain (
liberty
) work perfectly across the theme, including custom fields like admin notices (e.g.,esc_html__('For full documentation, visit: ', 'liberty')
). However, Redux-specific strings under theliberty-settings
text domain—such as section titles (e.g., “General Settings”), field labels, and a test string in$args['footer_credit']
(e.g., “Test Footer Credit”)—remain in English. These strings are present in myliberty-settings-fa_IR.po
file with their translations (e.g., “General Settings” translated toتنظیمات عمومی
, “Test Footer Credit” translated toتست اعتبار فوتر
), but Redux doesn’t apply them. Steps Taken to Resolve the Issue 1. Loading the Text DomainsMy theme’s primary text domain (
liberty
) is loaded infunctions.php
as follows:add_action('after_setup_theme', function() { load_theme_textdomain('liberty', get_template_directory() . '/languages'); });
This works perfectly for the theme’s translations. For the Redux settings, I’ve tried loading the
liberty-settings
text domain with various hooks to ensure proper timing:- Initially used
after_setup_theme
:
add_action('after_setup_theme', function() { load_textdomain('liberty-settings', get_template_directory() . '/languages/liberty-settings-fa_IR.mo'); });
- Then switched to
init
andadmin_init
with priority 5:
add_action('init', function() { load_textdomain('liberty-settings', get_template_directory() . '/languages/liberty-settings-fa_IR.mo'); }, 5); add_action('admin_init', function() { load_theme_textdomain('liberty-settings', get_template_directory() . '/languages'); }, 5);
- Then tried
admin_menu
andwp_loaded
to align with Redux’s rendering:
add_action('admin_menu', function() { load_theme_textdomain('liberty-settings', get_template_directory() . '/languages'); }, 5); add_action('wp_loaded', function() { load_theme_textdomain('liberty-settings', get_template_directory() . '/languages'); }, 5);
- I also attempted loading the text domain directly in
redux-config.php
after defining$opt_name
:
$opt_name = 'liberty_pro_options'; load_theme_textdomain('liberty-settings', get_template_directory() . '/languages');
This resulted in the following error:
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for domain liberty-settings was called too early. This usually indicates code in a plugin or theme running too early. Translations should be loaded on the init action or later. (This message was added in version 6.7.0.)
2. Setting the Text Domain in Redux
I specified the text domain in
redux-config.php
:$args['text_domain'] = 'liberty-settings'; $args['footer_credit'] = esc_html__('Test Footer Credit', 'liberty-settings'); Redux::set_args($opt_name, $args);
- The string “Test Footer Credit” is translated in
liberty-settings-fa_IR.po
asتست اعتبار فوتر
, but it still displays in English in the admin panel.
3. Using Filters to Force Translation
I tried forcing translations using Redux-specific filters:
add_filter('redux/liberty_pro_options/section', function($section) { if (isset($section['title'])) { $section['title'] = __($section['title'], 'liberty-settings'); } if (isset($section['desc'])) { $section['desc'] = __($section['desc'], 'liberty-settings'); } return $section; }, 99, 2); add_filter('redux/liberty_pro_options/field', function($field) { if (isset($field['title'])) { $field['title'] = __($field['title'], 'liberty-settings'); } if (isset($field['subtitle'])) { $field['subtitle'] = __($field['subtitle'], 'liberty-settings'); } if (isset($field['desc'])) { $field['desc'] = __($field['desc'], 'liberty-settings'); } return $field; }, 99, 2);
- I also tried a global
gettext
filter:
add_filter('gettext', function($translation, $text, $domain) { if ($domain === 'liberty-settings') { $translation = __($text, 'liberty-settings'); } return $translation; }, 99, 3);
- None of these filters resolved the issue for Redux strings.
4. Debugging the Text Domain Registration
I checked if the
liberty-settings
text domain was registered using:add_action('wp_loaded', function() { global $wp_textdomain_registry; error_log(print_r($wp_textdomain_registry->get('liberty-settings', 'theme'), true)); });
- Initially, nothing was logged, indicating the text domain wasn’t registered. After switching to
load_theme_textdomain
, the text domain was registered, but translations still didn’t apply.
5. Verifying the
.mo
FileI confirmed the
.mo
file exists:add_action('admin_init', function() { $mo_file = get_template_directory() . '/languages/liberty-settings-fa_IR.mo'; if (file_exists($mo_file)) { error_log('MO file exists: ' . $mo_file); } else { error_log('MO file does not exist: ' . $mo_file); } });
- Debug log confirmed the file’s presence:
[17-Apr-2025 16:10:46 UTC] MO file exists: C:\Users\Lion\Local Sites\test\app\public/wp-content/themes/liberty/languages/liberty-settings-fa_IR.mo
6. Testing with Loco Translate
- I used Loco Translate to verify the translations. The
liberty-settings-fa_IR.po
file contains all the necessary strings (e.g., “General Settings” translated toتنظیمات عمومی
, “Test Footer Credit” translated toتست اعتبار فوتر
). - I synced the
.po
file with the source code and saved it, but the translations still didn’t apply in the Redux panel.
7. Adjusting
page_priority
I changed the
page_priority
in$args
to test if rendering timing was the issue:'page_priority' => 50,
- This only affected the menu position in the admin panel and had no impact on translations.
8. Attempting to Use Redux’s Default Text Domain
I initially tried using Redux’s default text domain (
redux-framework
) for my strings, but this caused conflicts with my theme’s primary text domain (liberty
) and resulted in_load_textdomain_just_in_time
errors. That’s why I switched to a separate text domain (liberty-settings
) for Redux settings. Observations- The theme’s primary text domain (
liberty
) works perfectly for all theme translations, indicating that WordPress’s translation system is functioning correctly. - Redux seems to ignore the
liberty-settings
text domain for its sections and fields, possibly due to timing issues, an internal limitation, or a conflict with the primary text domain (liberty
). - The
_load_textdomain_just_in_time
error suggests that Redux might be attempting to load translations too early, especially after WordPress 6.7 introduced stricter translation loading rules.
Request for Assistance
Could you please help me understand why Redux isn’t recognizing my custom text domain (
liberty-settings
) for its sections and fields, while my theme’s primary text domain (liberty
) works fine? Is there a specific hook or method I should use to ensure translations are applied correctly forliberty-settings
in Redux? Additionally, any insights into handling the_load_textdomain_just_in_time
error with Redux would be greatly appreciated. I’d be happy to provide additional details or test any suggested solutions.Thanks in advance for your support!
Masoud Sadeghi
- You must be logged in to reply to this topic.