• Resolved gaspar

    (@gaspar)


    Hello!
    I debugged your plugin and found out the wrong locale gets loaded in load_textdomain() function.

    1) I use Qtranslate-x plugin (latest 3.4.6.8).
    2) I have set up 2 languages with “en_US” (default) and “ru_RU” locale.
    3) I switch to ru_RU. All other information gets correct language/locale/translations but “WooCommerce Products Per Page” not.
    4) load_textdomain() function gets wrong (default) locale (en_US).
    If i enter the code into functions.php file
    add_action(‘init’,function(){ echo get_locale(); exit; });
    it shows correct locale.

    How can i/we resolve this issue?

    • This topic was modified 8 years, 1 month ago by gaspar.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Hmm, thats strange! I haven’t heard anyone else about issues with loading the wrong locale.

    Could it be you’ve overwritten the translation files with wrong ones?
    Its first trying to load the translation from the WP Language directory, then only the ones in the plugin files.

    Cheers,
    Jeroen

    Thread Starter gaspar

    (@gaspar)

    Thanks for reply!
    I have no idea why this issue occurs with just this plugin.

    This is how i debug this issue.
    1) woocommerce-products-per-page.php, line 157 (2nd line in function load_textdomain()):
    $locale = apply_filters( ‘plugin_locale’, get_locale(), ‘woocommerce-products-per-page’ );
    echo($locale);

    it echoes “en_US”

    2) in functions.php
    add_action(‘init’,function(){ echo get_locale(); exit; });

    it echoes “ru_RU”

    So it does load translation file based on locale but it is the wrong one.

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Can you check what it says when you do echo get_local();?
    (so without the filter)

    Your default language is EN if I understand correctly..?

    Thanks,
    Jeroen

    Thread Starter gaspar

    (@gaspar)

    It is same (EN).
    Is something to do with plugin load order?
    Qtranslate-x gets loaded after your plugin?

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Sorry, I forgot to mention, but I meant what does it say when you use just the function below the line that outputs the wrong locale in my plugin?

    I’m not sure if its the load order. I actually didn’t even realise you were using a translating plugin (must’ve overread that in your message). Can you check what happens if you set the actual site language to RU?

    Cheers,
    Jeroen

    Thread Starter gaspar

    (@gaspar)

    I tested it, it always gets the default language (not chosen one by Qtranslate-X).

    Second question, i would like to make special translation.
    Usually the extra plugin translations are in /wp-content/languages/plugins folder (it does not have system russian translation for example – so it can reside this folder without overwritten by an update). Your plugin doesn’t support it?!

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Then I’d suspect it could indeed be the load order, possibly QT is using the filter to modify the locale, but it could be that filter isn’t added yet at the time my plugin is loaded.

    Since it is loading the proper default language, I won’t be able to investigate this QTranslate incompatibility since it is not a plugin that is specifically supported. I’d be happy to review any Pull request if you have one though.

    re 2) It should be supported, the code for it is right here: https://github.com/JeroenSormani/WooCommerce-Products-Per-Page/blob/master/woocommerce-products-per-page.php#L161

    Cheers,
    Jeroen

    Thread Starter gaspar

    (@gaspar)

    Thanks!
    I sorted everything out.
    1) The problem was Qtranslate-X Slug. It made several problems beside that. I switched it off. Your plugin is getting the right locale now!
    2) I assumed (as other plugins do) the translation files should be under plugins folder. I changed the location and it get’s right language files now.

    Regards!

    • This reply was modified 8 years, 1 month ago by gaspar.
    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Glad to hear its working now ??

    Have a great day!
    Jeroen

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Wrong locale gets loaded’ is closed to new replies.