• Resolved EA10

    (@ea10)


    I have a problem when using Loco Translate with WooCommerce, with having the translated files update-save in /wp-content/languages/plugins/.

    WooCommerce has it’s translations in /wp-content/plugins/woocommerce/i18n/languages/
    In this folder there are 2 .pot files, woocommerce.pot and woocommerce-admin.pot and po/mo files for each language.
    On the Loco management page only one .pot file is shown, woocommerce.pot, none of the files for admin translations show up. That’s ok for me as I only need to change translations in the frontend.

    I copied the po and mo file of the language I want to translate to the global folder /wp-content/languages/plugins/, it is recognized by Loco and changes to the file are saved correctly through Loco.

    But when viewing the site, translations are still loaded from the standard language file in WooCommerce plugins folder and not from the custom file in the global folder.

    Only when I delete the original file from Woocommerce folder, the custom/global file gets loaded. But this would have to be done every time there comes an update for WooCommerce.

    Is there any way to change this, so translations always get loaded from the global folder if they exist there?

    Many thanks in advance!

    PS all language folders and files involved are chmod 777

    https://wordpress.org/plugins/loco-translate/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Tim W

    (@timwhitlock)

    There are two issues here.

    1. The second POT file:
    Loco can’t currently handle multiple text domains per plugin. This is a restriction that will hopefully be resolved in the future, but you say for now this is not a problem for you.

    2. Files not loading from global languages folder:
    Loco does not control what files are loaded, or in what order – it controls only where they are saved and will always try to save them where you’ve already placed them.

    WordPress always checks the global languages directory second, so if a file is matched in your plugin folder for the same languages, it will be used. Look at the load_plugin_textdomain to see how this works.

    Thread Starter EA10

    (@ea10)

    Thank you!

    What is the recommended way to keep custom translations at plugin updates?

    Or shouldn’t I create languages files at all when the desired language already exists and I only need to change several wordings?

    Plugin Author Tim W

    (@timwhitlock)

    I suggest you try to use a filter to fix the problem of the default loading order.

    Take a look at the filters in the load_textdomain function — override_load_textdomain seems like a good candidate for avoiding the load of the plugin’s own language files. Returning true looks like it would then cause WordPress to load from the global languages directory.

    Thread Starter EA10

    (@ea10)

    Thanks, I tried adding
    add_filter( 'override_load_textdomain', '__return_true' );
    to functions.php but now it displays the original english strings instead of any translations. Any idea?

    Plugin Author Tim W

    (@timwhitlock)

    I’m afraid not, no. It was just a suggestion.

    Thread Starter EA10

    (@ea10)

    Ok thanks… may I ask how you handle to keep translations from being overridden during plugin updates?

    If the normal way really is to restore them from backup after any update, it would be a killer feature for Loco Translate to automate this somehow.

    Plugin Author Tim W

    (@timwhitlock)

    The same way you’ve already tried – using the global languages directory.

    Thread Starter EA10

    (@ea10)

    And then delete the original file from the plugins folder after any update?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Loco Translate & Woocommerce: Selection of translation files’ is closed to new replies.