1

I have a plugin YITH Wishlist in use and I want to override their translation with my own translation which I have included in my child theme.

So basically I created this folder: /mychildtheme/languages

and placed this file in it yith-woocommerce-wishlist-de_DE.mo / yith-woocommerce-wishlist-de_DE.po.

Within my functions.php I did the following:

add_action( 'plugins_loaded', 'yith_load_textdomain' );
function yith_load_textdomain() {
    unload_textdomain( 'yith-woocommerce-wishlist' );
  load_plugin_textdomain( 'yith-woocommerce-wishlist', false, get_stylesheet_directory_uri() . '/languages' );
}

But this has no effect. Does somebody knows how I can override a plugin text domain with my custom translations?

Thanks!

2 Answers 2

5

If you want to override a plugin text domain, create (if not exist) a folder named languages and another one plugins (in languages) in the wp-content folder.

This folders is intended, with the template and file hierarchy, to be load upon the other that could exist.

When you update a plugin, text domain that you modified and copied into this folder will not be erase. It's up to you to maintain it up to date.

2
  • Hello @benoti, I did that, but the changes are not visible on the frontend.
    – Torben
    Commented Nov 7, 2016 at 7:29
  • so you put yith-woocommerce-wishlist-de_DE.mo and yith-woocommerce-wishlist-de_DE.po in: wp-content\languages\plugins ? I have done exactly that for the yith custom login plugin and it worked fine, so shouldn't be a problem with yith plugins. Make sure you remove your code from functions.php
    – Nat
    Commented Nov 9, 2016 at 12:57
0

You should not be modifying a plug-in's text domain like that. It forces you to have to change it over and over again each time the plugin updates.

If it does not already have it, create a folder /languages in the plugin's directory. In there place a file that contains all the translated text that matches the code you specify in your wp-config.php file. A program like Poedit will help you do this.

1
  • When I do that - add a folder to the plugins directory - it will be deleted once I update the plugin...?
    – Torben
    Commented Nov 7, 2016 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.