Background of the issue:
I am trying to translate some of the strings on my website, which is set to Latvian language using WPML. I installed WooCommerce, and WooCommerce shows its strings as English on the string translation page. I have added translations to the strings there, but they are not being applied on the website. I customized the WooCommerce template and wrote code like: <div id="payment" class="woocommerce-checkout-payment"> <div class="title"> <h2><?php esc_html_e('Maksājuma metodes', 'woocommerce'); ?></h2> </div> .... After which, I would go to string translation and change the 'Maksājuma metodes' string default language from English to Latvian and then translate this string back to English, and now it works.
But when I translate strign that has default language of english to latvian it does not get shown on the frontend on latvian language of the page. Another language like russian works well for this translated english string. but not for latvian which is the default language of my website...
Symptoms:
Translations added to WooCommerce strings are not being applied on the website if the default language of the string is set to english and is translated to latvian.
Questions:
Is there any other way to translate WooCommerce strings without creating custom templates?
Why are the translations not being applied even after adding them in the string translation page when translating from default string language to pages default language?
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: Europe/Madrid (GMT+02:00)
Hi,
I would eventually also need to request temporary access (WP-Admin and FTP) to your site
– preferably to a test site where the problem has been replicated if possible –
in order to be of better help and check if some configurations might need to be changed
Your next answer will be private which means only you and I have access to it.
❌ Please backup your database and website ❌
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please add the Links to the […] Edit Screen, the Page/Post where you insert the […] and the corresponding Front End Page/Screen
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: Europe/Madrid (GMT+02:00)
Hi,
could you please try clearing the contents of /wp-content/languages on your staging environment and check whether the files are regenerated afterward?
It looks like the translations exist but aren't being fetched correctly.
Can it be related if I use custom plugin that overrides cart-empty.php using:
add_filter('woocommerce_locate_template', [$this, '_custom_plugin_locate_template'], 99999, 3);
and then in override cart-empty.php with something like:
do_action( 'woocommerce_cart_is_empty' );
so the string is pulled from woocommerce in my custom plugin and thus can potentially be untranslatable to default language? Or it must work anyway?
Maybe there is some way to use correct context of the language when calling actions or variables from woocommerce inside my custom overriden files, like language specific:
do_action( 'woocommerce_cart_is_empty' ); or some other approach?
I also tried removing the custom templates from the plugin so it uses woocommerce templates and still english version appeas on front, even though default is latvian.
I tried translating other plugins, tried also disabling plugins, reanabling them but it did not work. When the default language domain for string is set to English and it is translated to Latvian and my website is in Latvian as default language it just does not work. Strings still displayed in default string language for default webpage language. When I choose any other language (secondary) - all works well...