magento/magento2

js-translation.json generation incomplete

AlexandreKhayrullin opened this issue · 19 comments

Preconditions

The Magento used is the "develop" branch.
PHP: PHP 7.0.10-1+deb.sury.org~xenial+1

Steps to reproduce

  1. Install a locale pack on Magento (in this case, the locale is es_ES)
  2. Set Magento in production mode.
  3. Display a UiComponent on frontend using the installed locale

Expected result

  1. The texts on the UiComponent are correctly translated

Actual result

  1. The texts remain in English (or, rather, use the translation keys)

It seems that the generation of js-translation.json is inconsistent between developer and production modes.
In production mode, the JSON either contains very few values (see js-translation.production.json in the attached ZIP file) or just an empty array. In developer mode, the JSON contains a lot more strings (see js-translation.developer.json in the attached ZIP file) , enough to make the UiComponents translatable.

js-translation.zip

I have the same issue with ar-json - not always Arabic files are generated in the JSON.

We expect that updating the CSV file should also update the Knockout JS files and Magento translation but it does not - this include local storage translation API

Have the same issue with a clean Magento 2 install with a valid language pack. It's missing a lot of translations.

I've tested and problem persists also in Version 2.1.6

I found the problem mostly in Checkout

Same problem here. I used the workaround explained here: #2056 (comment)

Also having trouble with this situation. Especially with the "Place order now" button. Can't get it translated. Not using CSV, not using complete language packs and inline translation doesn't work either.

I just had it in developer mode too. This happens so often now that I remove the js-translation.json and run setup:static-content:deploy for my local language every time a translation doesn't work.

We have created a work-around with a custom script which converts all .csv files to js-translation.json files and then manually rewrite requests to js-translation.json in our web-server to our custom files and it works everytime.

@PascalBrouwers Thank you for the information, but that didn't work for me either. It's both in dev mode and in prod mode. I am wondering; does this issue occur in the checkout too? For me it's only in the checkout. Do you use a custom OneStepCheckout by for example Hungersoft or Magestore?

We do have Magestore OSC, but it doesn't matter where the translation is when the entire js-translation.json file is empty :)

Ah, i found out that the translations in our Magestore OSC broke because of $t('string') weren't the same as the data-bind in the span. I solved it by matching the data-binds (see screenshot). Maybe it might help you too.
solution

Same issue here, $t translations work fine in developer mode, but fails in production mode

@cjohansson please can you share this solution of making a custom json file as I was considering doing the same. I would really appreciate it - is it a module or snippet that you can opensource?

rm pub/static/<area>/<vendor>/<theme>/<lang>/js-translation.json
setup:static-content:deploy <lang> --theme=<vendor>/<theme>

generated proper js-translation.json for <lang>, and translations work fine.

@AlexandreKhayrullin, thank you for your report.
We've created internal ticket(s) MAGETWO-84070 to track progress on the issue.

Any update on this issue?

A problem in 2.3 it seems.

I'm working on a Persian language project and have same issue experience.
Magento 2.2.7 #10860

Hi @engcom-Bravo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


Hello @AlexandreKhayrullin
Unfortunately, I cannot reproduce this issue by steps you described on 2.4-develop
Please feel free to comment, reopen or create a new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.