Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento 2.1.0 Js Translations Not Working #7525

Closed
grazianodimaio opened this issue Nov 22, 2016 · 29 comments
Closed

Magento 2.1.0 Js Translations Not Working #7525

grazianodimaio opened this issue Nov 22, 2016 · 29 comments
Labels
bug report Component: Translation Fixed in 2.1.x The issue has been fixed in 2.1 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@grazianodimaio
Copy link

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.

@JDavidVR
Copy link
Contributor

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

@vasilii-b
Copy link

Confirm this one on M2.2.0-dev too

@BeatDirector
Copy link

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

@grazianodimaio
Copy link
Author

@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.

@slopukhov
Copy link
Contributor

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

@grazianodimaio
Copy link
Author

grazianodimaio commented Dec 1, 2016

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 ?

@artis-ozolins
Copy link

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

@sitepodmatt
Copy link

sitepodmatt commented Dec 8, 2016

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

@Khaleel
Copy link

Khaleel commented Dec 18, 2016

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

@slackerzz
Copy link
Member

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!

@hostep
Copy link
Contributor

hostep commented Dec 19, 2016

@slackerzz: this is being tracked here: #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: #7862

@mgomma
Copy link

mgomma commented Jan 15, 2017

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

@Flamestyle
Copy link

Flamestyle commented Jan 28, 2017

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?

@andreymoskvenkov
Copy link

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.

@vherasymenko
Copy link

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

@versdivers
Copy link

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

@Khaleel
Copy link

Khaleel commented May 22, 2017

Still not working in EE 2.1.16

@fahu
Copy link
Contributor

fahu commented Jul 20, 2017

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

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 21, 2017
@tommybds
Copy link

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

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-72250

@Flamestyle
Copy link

Flamestyle commented Sep 5, 2017

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.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Component: Translation labels Sep 11, 2017
@kervin
Copy link

kervin commented Sep 22, 2017

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?

@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Oct 6, 2017
@kervin
Copy link

kervin commented Oct 23, 2017

Is 2.1.10 available?

@joinso
Copy link

joinso commented Nov 6, 2017

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

@devamitbera
Copy link

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

Is this issue resolved at 2.2 or not?

Thanks

Amit Bera

@Khaleel
Copy link

Khaleel commented Nov 16, 2017

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

@Tomasz-Silpion
Copy link
Member

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

#8508
#10673

which seem to be already solved on develop branch thanks to the fc34d7b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Translation Fixed in 2.1.x The issue has been fixed in 2.1 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests