Magento2: Magento 2.1.0 Js Translations Not Working

Created on 22 Nov 2016  路  29Comments  路  Source: magento/magento2

All the JS error messages not translated

Preconditions


  1. Magento CE 2.1.0 in developer mode

Steps to reproduce

  1. Go to a grouped product page
  2. Add product without selecting the quantity
  3. Press add to cart

Expected result

  1. Js error message translated in italian

Actual result

  1. The Js is in english even if the csv has the translation in it.

This is a great problem because every js-generated message is not translated.

Translation Fixed in 2.1.x Format is valid Ready for Work bug report

Most helpful comment

i can confirm what @artis-ozolins wrote:

...when js-translation.json file is generated Magento does not include translations from theme

this is a major bug in the translation system!

All 29 comments

I was facing a similar issue, can you share your .csv file

Confirm this one on M2.2.0-dev too

Same issue in version 2.1.2.

I found workaround for lib/web/mage/validation.js to be translated over .csv

Original
Line: 567
if (counter < passwordMinCharacterSets) { result = false; validator.passwordErrorMessage = $.mage.__( "Minimum of different classes of characters in password is %1." + " Classes of characters: Lower Case, Upper Case, Digits, Special Characters." ).replace('%1', passwordMinCharacterSets); }

Edit:
if (counter < passwordMinCharacterSets) { result = false; validator.passwordErrorMessage = $.mage.__( "Minimum of different classes of characters in password is %1. Classes of characters: Lower Case, Upper Case, Digits, Special Characters." ).replace('%1', passwordMinCharacterSets); }
Set text as one line without + between

@JDavidVR
Hi David! Here is my CSV translations file

it_IT.csv.zip

@BeatDirector
Ok, thanks, but the problem is EVERYWHERE a JS error message is displayed.
In example, customer registration, grouped add to cart, even the payment error message "Unable to place order" is translated.

The translation system it's not working at all in JS.

@grazianodimaio
Issue was fixed in MAGETWO-55900. Please, check the develop branch and leave a feedback if it works for you.

Hi,

no, it doesn't work at all, even some files are very different from my Magento2 version.

I have the 2.1.0 Version.

There is a bugfix for 2.1.0 version ?

Hello,

For those who are not having any JS translations working - when js-translation.json file is generated Magento does not include translations from theme. Only translations from module locale files will be used, so do not use theme for translating strings.

And remember to redeploy your static files:
rm -rf pub/static/*
rm -rf var/view_preprocessed/*
bin/magento setup:static-content:deploy

If your locale is not deployed, then deploy it directly by adding locale parameter i.e.:

bin/magento setup:static-content:deploy sv_SE

Rebasing our work on top of develop we can get this to work finally. The json file is now generated:
pub/static/frontend/Acme/acme_luma/en_GB/js-translation.json

@artis-ozolins setup-static step not necessary in developer mode once you clear pub/static and var/ directories.

FYI, We use an app/i18n language pack so can't comment on theme level translates

Is this because the JSON is then store in localStorage via mage translate for knockout as I get issues on Safari and cart - sometimes it appears and sometimes it does not

i can confirm what @artis-ozolins wrote:

...when js-translation.json file is generated Magento does not include translations from theme

this is a major bug in the translation system!

@slackerzz: this is being tracked here: https://github.com/magento/magento2/issues/6563

And in M 2.1.3 they introduced a new bug, which generates the incorrect js-translation.json file when you deploy multiple locale's at the same time: https://github.com/magento/magento2/issues/7862

I have the same Issue and tried
rm -rf pub/static/*
rm -rf var/view_preprocessed/*
bin/magento setup:static-content:deploy

But still not see all translated strings

Any updates about that issue

Guys, when you create a language package same official docs, you add 4 files: composer.json, language.hml, registration.php, xx_XX.csv.
After your commands like this?

cd /var/www/html
rm -rf pub/static/*
rm -rf var/view_preprocessed/*
php /var/www/html/bin/magento cache:clean
bin/magento setup:static-content:deploy --theme Magento/backend en_US
bin/magento setup:static-content:deploy --theme Agestor/default xx_XX
php /var/www/html/bin/magento cache:clean

Or you use other commands?
And write please for remove need only remove this 4 files and repeat these commands?

It does not work, because "Translation" class is a singleton and during the static content deploy it loads translations or en_US for "blank" theme and once you have some translations in your custom theme for the same "en_US" locale (example: "Add To Cart" => "Add To Bag"), which goes After "blank" in compiling queue, then Magento will not load your translations, because all translations from "blank" theme for "en_US" have been already loaded. This issue appears not only in static-content-deply, but also in emails, when "emulation" methods are running. Possible solution is: to re-load reanslations, when "setDesignTheme" method is called (just to override it and add some code :) ). It is like a workaround.

hello @grazianodimaio , thank you for the report, the ticket is created MAGETWO-66898.

How is this coming along? Can we have an update?

Still not working in EE 2.1.16

Experiencing the same issue on CE 2.1.7. Can anybody provide a workaround for that issue?

EDIT (24.07.2017): When executing the command
magento setup:static-content:deploy xx_XX
for each language separate everything works as it should.

So instead of using:
php bin/magento setup:static-content:deploy en_US de_DE it_IT fr_FR es_ES

use
php bin/magento setup:static-content:deploy en_US
php bin/magento setup:static-content:deploy de_DE
php bin/magento setup:static-content:deploy it_IT
php bin/magento setup:static-content:deploy fr_FR
php bin/magento setup:static-content:deploy es_ES

Found out that my translations problems were when I deploy files.

with this :php bin/magento setup:static-content:deploy
problem with CSS and JS

php bin/magento setup:static-content:deploy -l en_US -l fr_FR
Problems with some translations not working (due to overwriting)

php bin/magento setup:static-content:deploy -l fr_FR
No more problems

So final solution for me was to launch these line in a upgrade.sh file at the root of magento :

php -f bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -l fr_FR
php bin/magento cache:flush

Internal ticket to track issue progress: MAGETWO-72250

More problems: I tried to change the translation for form contact, but it does not work. Tried everything.
Name,Your name,module,Magento_Contact
"Name","Your name",module,Magento_Contact
Shows anyway - Name.

Any updates on this?

We have 15 stores and we have to deploy store by store. Our deployment takes 20 minutes instead of 5 minutes because of this bug...

Is this fixed in 2.2.0?

Hi @grazianodimaio the issue has been fixed in 2.1.10 and will be available soon

Is 2.1.10 available?

Hi!

I try to add this translation (es_ES):
"Minimum of different classes of characters in password is %1. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.","La contraseña ha de tener más de %1 caracteres, y ha de incluir al menos una letra mayúscula, una letra minúscula y un número o simbolo especial (guión, parentesis, puntos, ...)","module","Magento_Customer"

In /MAGENTO_INSTALL_PATH/app/design/frontend/vendor/theme_name/i18n/es_ES.csv

and then exceute this:

php -f bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -l es_ES
php bin/magento cache:flush

But it doesn't work.
Still showing the previous translation.

Any idea?
My Magento version: CE 2.2.0

@magento-engcom-team , seem that issue still in magento 2.2 version.

Is this issue resolved at 2.2 or not?

Thanks

Amit Bera

Still not working in EE 2.1.16

I suggest resorting to a JSON fix and manually updating. KnockoutJS and localstorage and known for being unreliable and notoriously slow.. so even adding this in translations json is not a guarantee it will appear

As for now best option is to use own module for translations not to fall into following issues

https://github.com/magento/magento2/issues/8508
https://github.com/magento/magento2/issues/10673

which seem to be already solved on develop branch thanks to the https://github.com/magento/magento2/commit/fc34d7bf5afce2db5f6019dcb5c259e1178fb3dc

Was this page helpful?
0 / 5 - 0 ratings