• Resolved masoud4x4

    (@masoud2018)


    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 the liberty-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 the liberty-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 my liberty-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 Domains

    My theme’s primary text domain (liberty) is loaded in functions.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 and admin_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 and wp_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 File

    I 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 for liberty-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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Kev Provance

    (@kprovance)

    The common issue with the _load_textdomain_just_in_time notice is that the get_plugin_data() API needs to have the third parameter set to false to avoid the expected loaded translations. That error occurs when they aren’t loaded and that API is called. It’s a change WP made without really telling anyone.

    As long as you are loading your Redux config and the load_theme_textdomain on an init hook, the translations will work as expected.

    This really isn’t a Redux issue, it’s a theme development issue beyond the scope of our support. If you have access to ChatGTP or Grok, that are very useful for debugging issues.

    Thread Starter masoud4x4

    (@masoud2018)

    Dear Redux Support Team,

    Thank you for your response and guidance. To ensure the issue isn’t theme-related and to avoid the _load_textdomain_just_in_time notice, we defined a new text domain, liberty-settings. We confirmed it loads correctly using test strings in both front-end and back-end, verified by Loco Translate and logs. However, these translations are not applied to Redux menus (e.g., “General Settings”) or field descriptions (e.g., “Logo”, “Width”).

    Interestingly, the same string (“Advanced Options”) translates correctly in an admin notice but not within Redux fields (see attached screenshot). We’ve ruled out caching issues, and logs confirm liberty-settings is loaded properly. Could you please advise on how to ensure Redux uses our custom text domain for menus and fields?

    // The text to appear in the admin menu.
    'menu_title' => __('Advanced Options', 'liberty-settings'),
    
    // The text to appear on the page title.
    'page_title' => __('Advanced Options', 'liberty-settings'),

    Attachment: [Screenshot showing “Advanced Options” translated in the admin notice but not in Redux fields]

    As mentioned earlier, we were able to verify that the new domain name was loaded correctly, but it appears that Redux processes translations differently than WordPress itself.

    Log:
    [19-Apr-2025 08:56:59 UTC] Text domain loaded successfully: liberty-settings
    [19-Apr-2025 08:56:59 UTC] Translated ‘Support’: پشتیبانی
    [19-Apr-2025 08:56:59 UTC] liberty-settings text domain is loaded.
    [19-Apr-2025 08:56:59 UTC] MO file exists: C:\Users\Lion\Local Sites\test\app\public/wp-content/themes/liberty/languages/liberty-settings-fa_IR.mo

    Best regards,
    Masoud Sadeghi

    • This reply was modified 2 weeks, 1 day ago by masoud4x4. Reason: Code added
    Thread Starter masoud4x4

    (@masoud2018)

    It should be noted that we repeated the tests with both the “__” and “esc_html__” translation functions, but the problem is not related to the functions either.

    • This reply was modified 2 weeks, 1 day ago by masoud4x4.
    Plugin Author Kev Provance

    (@kprovance)

    Redux isn’t handling anything, you see. You are adding translator’s into your Redux config, which is a PHP file your theme is loading. The translators API still does the work, not Redux. The issue is when you are loading your config, which sound like it still happening before the load_theme_textdomain

    I have no idea how you’ve chosen to structure your theme and why I can’t advise on this. It’s about loading order, which isn’t a Redux issue as Redux is not doing any actual translation.

    Welcome to theme development. It’s chock full of issues such as this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.