9

I'm trying to translate some text in the checkout page:

"Provided Zip/Postal Code seems to be invalid."

However, when I add the following to frontend/..theme../Magento_Checkout/i18n/en_US.csv and re-deploy, the translation isn't there:

"Provided Zip/Postal Code seems to be invalid.","Test."

I cleared cache as well. What am I doing wrong?

  • check my updated answer. I hope now working for you. – Suresh Chikani Oct 24 '16 at 9:52
14

Create a directory app/i18n/Vendorname/en_US

Issue command:

bin/magento i18n:collect-phrases --output "app/i18n/Vendorname/en_US/en_US.csv" --magento This will collect all the translatable phrases in csv file and place it in the specified path. Make changes to the csv file as per your requirement and when ready issue command:

bin/magento i18n:pack app/i18n/Vendorname/en_US/en_US.csv -d en_US

This will deploy the translations from your file.

clear the cache etc and you should see your changes.

  • This looks promising. It says the language package was saved successfully but the translation is still not there.. – Cake Oct 24 '16 at 9:37
  • When I do the collect-phrases command again, the translation is back to what it was. Why isn't it saving? – Cake Oct 24 '16 at 9:40
  • That's normal behavior, when you recollect phrases it overrides your changes because Magento has recollected all default phrases. Process is you collect phrases, make your changes and deploy them, once deployed you can go in the concerned module let's say you made change for Add to Cart to Add to Bag, you can go to vendor/module-catalog/i18n/en_US.csv and look for your change. Just retested this and it works as it should. Make sure you're changing the second instance in translation and clearing the cache properly. You can also try deploying static content once again. – Devtype Oct 24 '16 at 9:52
  • Great thanks, it works indeed. However, some translations don't come through. The 'Example:' translation and 'Required fields' aren't translated. How come? – Cake Oct 24 '16 at 10:56
  • Found the problem. I had to php bin/magento setup:upgrade. After that my site was messed up, but then deplying the theme fixed it. No idea why this worked. Thanks – Cake Oct 24 '16 at 11:04
3

You can change only text which is written in translation

Like : $this->__("Sample Taxt");

Suggested text not written in translation so you can not change it with translation.

If you want to change it, you can find it in JS file which is located :

vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rates-validator.js

Note : You have to override JS file to in your theme.

Delete pub/static/*

Run Command :

php bin/magento setup:static-content:deploy 

php bin/magento cache:clean

Delete browser cache.

  • I tried this and it didn't work for some reason. – Cake Oct 24 '16 at 8:51
  • I copied that file, changed the translation, and put it in app/design/frontend/<vendor>/<theme>/Magento_Checkout/web/js/model, re-deployed and cleaned cache. But no change.. – Cake Oct 24 '16 at 9:30
  • check my updated answer. I hope now working for you. – Suresh Chikani Oct 24 '16 at 9:37
  • This indeed worked. However, the solution provided by Devtype suits my needs more in this case. Thanks for the help! :) – Cake Oct 24 '16 at 11:05
1

Had the same problem on my Magento 2 website, tried all sorts of suggestions how to fix it but the only thing that worked for me was -

  1. go to /pub/static/frontend/<theme>/<theme>/<language for example pl_PL>

  2. Find js-translation.json and delete it (make a copy of it just in case!)

  3. Go back to your magento root folder and run php bin/magento setup:static-content:deploy pl_PL

  4. Then run php bin/magento cache:flush

That's it. If you go back to /pub/static/frontend/<theme>/<theme>/<language for example pl_PL> folder, notice that js-translation.json have been generated again.

This problem happens because when you run static deploy, magento generates js-translation.json file with all your translations inserted into this one file and calls it in every time the page is loaded. So when it's already generated and usually empty, it cannot overwrite it with new information. By deleting it and regenerating it will solve the problem.

Hope this is going to help somebody.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.