JS Translation not working
-
07-02-2021 - |
Question
I'm having an issue with some translations in Magento 2 2.3.0. My store is in french, most of the text works fine.
It seems that the problem occurs only with content that come from JS (AJAX and template).
Example:
<span data-bind="i18n: 'View and Edit Cart'">View and Edit Cart</span>
I have the same problem with the state/province in the shipping calculation, it's in the wrong locale.
If I check in js-translation.json, there's around 300 translations and "View and Edit Cart" is one of them. I don't know where does these translations come from, my translation CSV has +9k terms.
I tried switching between dev and prod mode to see if the generation changed, but same thing.
Also, between every attempt, I ran these commands
rm -rf var/generation/* var/di/* var/cache/* var/page_cache/*
var/view_preprocessed/* pub/static/*;
bin/magento setup:upgrade;
bin/magento setup:di:compile;
bin/magento setup:static-content:deploy --theme=[my theme] fr_CA -f;
bin/magento cache:flush;
bin/magento indexer:reindex;
Magento: Community Edition 2.3.0
PHP: 7.2.13
Thank you
Solution 2
Alright, I figured it out, kinda.
The problem with "View and Edit Cart" seems to have fixed itself somehow, I didn't change anything and just started to show up in the right language.
For popup massage You added %1 to your shopping cart.
, I'm guessing it was changed in a patch because now there's a url on the "cart", so it's now You added %1 to your <a href=""%2"">shopping cart</a>.
so it was never translated. (I could be wrong about this).
For the state/province translations, I found out that you need to make them in the database by hand in the table directory_country_region_name
.
OTHER TIPS
Check in below path if the translation is getting updated
app/code/Magento/Checkout/i18n/fr_CA.csv