Hello dodog,
Thank you for contacting WooCommerce support.
I understand you’re experiencing an issue where each WooCommerce update overwrites your custom language file, causing your translated strings to revert to English.
To help prevent this, have you had a chance to review our documentation on creating custom translations? You can find it here: WooCommerce Localization Guide. It explains how to safely store your translations so they aren’t affected during updates.
Let me know if you have any questions. 🙂
Best regards.
Thread Starter
dodog
(@dodog)
Hi @doublezed2,
Yes, I have read the WooCommerce Localization Guide. I translated the files using the Poedit as recommended and placed the translation in wp-content/languages/plugins.
Making your translation upgrade safe
WooCommerce keeps translations in wp-content/languages/plugins, like all other plugins. But if you wish to include a custom translation, you can use the directory wp-content/languages/woocommerce, or you can use the snippet.
But it is overwritten on every update.
Hi there!
I understand your concern. Since you mentioned placing the translation file in the wp-content/languages/plugins
directory to preserve it after updates, could you please try placing the translation file in the wp-content/languages/woocommerce
directory instead and see if that works for you?
Also, please try using the custom code mentioned in the following article to make your translation upgrade-safe:
https://developer.woocommerce.com/docs/making-your-translation-upgrade-safe/
Let us know how it goes!
Thread Starter
dodog
(@dodog)
Hi @shahzeenfarooq,
thank you, adding the following code to functions.php solved the issue.
// 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;
}
Hi there!
You’re very welcome, I’m glad to hear that the code solved the issue!
If you have a moment, we’d really appreciate it if you could leave a review for the WooCommerce plugin. Your feedback helps us continue to improve and support users like you.
You can leave a review here:
🔗 https://wordpress.org/plugins/woocommerce/#reviews
Thanks again for using WooCommerce, and feel free to reach out anytime you need assistance!