3

I've been encountering an issue where I am unable to translate fields in Magento 2 checkout.

Steps I have take:

  1. Created app/design/frontend/Company/theme/i18n/en_US.csv
  2. Added strings to update:

    "Review & Payments", "Review & Pay", "Apply Discount Code", "Apply Promotional Code"

  3. Ran the following:

    bin/magento setup:upgrade
    bin/magento cache:flush
    php bin/magento setup:content-static:deploy en_US
    

When refreshing the frontend, the translation in the checkout does not update. However, using the same steps works for all other front-end aspects of the site.

4
  • I've read over that and it doesn't work on the checkout pages. All other pages work well with my approach. I've been reading that it might be related to the js-translation and knockout not updating but haven't found a solution yet.
    – Eirik
    Nov 22, 2017 at 18:40
  • Check if your translation are in js-translation.js in your pub/static/frontend/vendor/theme/en_US Nov 22, 2017 at 20:38
  • The file is there but is returning only [] which I believe means it is not properly collecting the KnockOut translations. I found a post suggesting moving the templates from the checkout into the custom theme and just updating the translation there, and that would work in the short run but we are also planning a french version down the road and at that point would be back where we started.
    – Eirik
    Nov 22, 2017 at 20:53

2 Answers 2

3

After much head banging and trying I finally figured out what the problem was. Localizing inside a theme such as app/design/frontend/Company/theme/i18n/en_US.csv does appear to get incorporated into the knock-out translations in the checkout. Why? I'm not sure, but I did come up with a solution that worked by creating an entire language pack.

Step 1, create a CSV of all translatable phrases used in the store. Run the following in ssh:

php bin/magento i18n:collect-phrases -o en_US.csv -m

Step 2, create a language pack such as app/i18n/CompanyName/en_US/ instructions on creating dictionaries and language packs are available in the Magento 2 developer documentation at http://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-i18n.html

Step 3, Update the phrases in the language pack to match the translation and localization needs

Step 4, refresh caches and deploy via ssh:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy en_US

A full write up including each step for creating a language pack can be found at http://www.ecommercegorilla.com/translation-localization-of-a-magento-2-store/

1
  • 3
    bin/magento i18n:collect-phrases -o en_NZ.csv -m In Phrase.php line 90: Missed phrase Any ideas? Feb 22, 2019 at 4:33
1

Before you delete this empty file

Normally this file is generated by language you have to launch a

php bin/magento setup:static-content:deploy fr_FR en_US 

tell me if that work

3
  • I am using php bin/magento setup:content-static:deploy en_US (we don't have a french translation yet)
    – Eirik
    Nov 22, 2017 at 21:27
  • Ok it's just an example this work for you? Nov 22, 2017 at 21:28
  • Unfortunately no it does not. It creates the js-translation file but it only contains []
    – Eirik
    Nov 24, 2017 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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