0

I got a shop with 4 different languages en/de/fr/it. Now I installed translation modules which have their files under app/i18n additionally I have a custom theme under with language files under app/design/frontend/mine/custom/i18n

all that seems to work fine if I use php. All translations are present. If I use js, the translations are not present. I checked the js-translation.json it regenerates during static file generation but does not include the translation strings. But it is also not empty. A fraction of translations is added. If I manually add my string for testing then it's being translated in js. So it's just not added for some reason.

Does someone know why or have a hint how I can track that issue down?

thx

1 Answer 1

1

Are you writing JS translation in a .js file or in a .phtml ?

To generate the js-translation.json file, Magento will scan all .js and .html project files, but not .phtml or .php ones.

When Magento detect a string (in .js or .html), it looks inside the CSV translations files and if it match, Magento put the translation inside the js-translation.json file.

This can be why you don't find your strings in your js-translation.json.

TLDR:

When you write javascript code in a .phtml file, you should use the php function __() to translate your content.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.