• Resolved etmanko

    (@etmanko)


    Dear all,

    sorry for this type of question but i have problem with translation woocommerce for some sentence in my language (Slovakia). Due to law in our country is needed to change text for one field. I used loco for translation fields what works perfect but my main problem is that after some time my translation is override somehow (i didn’t do any updaet update theme i don’t do anything just leave my whole web untouched) to original slovak translation, where my translated string are overriden. I already used your help page with translation:

    // Code to be placed in functions.php of your theme or a custom plugin file.
    add_filter( ‘load_textdomain_mofile’, ‘load_custom_plugin_translation_file’, 10, 2 );

    /*
    * Replace ‘textdomain’ with your plugin’s textdomain. e.g. ‘woocommerce’.
    * File to be named, for example, yourtranslationfile-en_GB.mo
    * File to be placed, for example, wp-content/lanaguages/textdomain/yourtranslationfile-en_GB.mo
    */
    function load_custom_plugin_translation_file( $mofile, $domain ) {
    if ( ‘textdomain’ === $domain ) {
    $mofile = WP_LANG_DIR . ‘/textdomain/yourtranslationfile-‘ . get_locale() . ‘.mo’;
    }
    return $mofile;
    }

    but this unfortunatelly didn’t worked.

    I tried to change permission of translated file to only read but was overrided again due to woocommerce was installed under server permission.

    I really don’t know where problem could be and i really appreciate your helps or advice.

    Many thanks

    https://www.ads-software.com/plugins/woocommerce/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    The code above has not been modified – did you change it to load a custom file or use what you pasted (which won’t work)?

    Thread Starter etmanko

    (@etmanko)

    Hi Mike,

    i replaced if ( ‘textdomain’ === $domain ) {
    to if ( ‘woocommerce’ === $domain ) {
    and $mofile = WP_LANG_DIR . ‘/textdomain/yourtranslationfile-‘
    to $mofile = WP_LANG_DIR . ‘/wp-content/languages/SK.po’ . get_locale() . ‘.mo’;

    my translated language was saved in file SK.po and this will not working, translation was original in english.

    Many thanks

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    You need a mo file, not the po file. Also the name in your snippet was wrong. It is looking for :

    SK.poSK.mo

    in your case which is wrong ??

    Thread Starter etmanko

    (@etmanko)

    I changed it to:
    /*
    * Replace ‘textdomain’ with your plugin’s textdomain. e.g. ‘woocommerce’.
    * File to be named, for example, yourtranslationfile-en_GB.mo
    * File to be placed, for example, wp-content/lanaguages/textdomain/yourtranslationfile-en_GB.mo
    */
    function load_custom_plugin_translation_file( $mofile, $domain ) {
    if ( ‘woocommerce’ === $domain ) {
    $mofile = WP_LANG_DIR . ‘/wp-content/languages/sk_SK’ . get_locale() . ‘.mo’;
    }
    return $mofile;
    }

    but still english translation.

    in wp-content/languages/ i have file sk_SK.mo and sk_SK.po

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    rename it to wc-sk_SK.mo, and change the sk_SK part in your snippet to wc-

    Thread Starter etmanko

    (@etmanko)

    ouch i see the script that locale are dynamically selected.
    i changed my code to: $mofile = WP_LANG_DIR . ‘/wp-content/languages/wc-‘ . get_locale() . ‘.mo’;

    file on ftp renamed to wc-sk_SK.mo but still same english language on page ?? i really don’t understand. if i change url for static ‘/wp-content/languages/wc-sk_SK.mo’; still english language was used

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    what does echo get_locale(); give you? I wonder if the code is wrong.

    Thread Starter etmanko

    (@etmanko)

    Hello,

    i put your code into function.php and on the page is locale: sk_SK so it should be correct.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Ok, so which strings are missing, or are not strings translated? What about the backend, is that translated?

    Thread Starter etmanko

    (@etmanko)

    There is not missing string. In our country i need to change translation becouse some string are translatted incorrectly.
    for example backordered is translated as returned in my language in its tricky in checkout. In total i founded that 4 strings are not correcnt and not aligned with our law, therefore i did translation using Loco and save it. This works some hours but from unexpected reason was my translated file overriden with original woocommerce file translation where i have again incorrect translated strings.

    I don’t know why filter not working but this make me sad as i did translation as last step in woocommerce configuration and as i am very beginer it take for me long time.

    Any help how setup woocommerce to not override translated translation with original translation?

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Just the ‘load_custom_plugin_translation_file’ snippet method above which does work my end. It must be to do with the naming of the files – I cannot see what else it could be.

    If there are not many strings to correct, how about using ‘say what’ instead?

    Thread Starter etmanko

    (@etmanko)

    Sorry, what is ‘say what’?

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Thread Starter etmanko

    (@etmanko)

    Mike,

    super this is sufficient for me. I hope translation will not be overriden again. I translated 5 strings with ‘say what’

    Many thanks for your time and support.

    Etmanko,
    please, what you write in the “Text domain”?
    I also solve unwanted changes in Slovak translation module woocommerce.
    Thanks.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Language override’ is closed to new replies.