magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Problem with the translations from javascript in Magento 2.2.2 #73

Open magento-engcom-team opened 6 years ago

magento-engcom-team commented 6 years ago

Hi! I'm developing a project on Magento 2.2.2 and I don't know if it's a new bug or I'm not doing well the correct steps when I try to do a translation from javascript and it works if I do it from a static text...

The problem comes if I try to translate using a variable. In that case the translation is not done correctly and it does not look for the associated translation that is generated in the file js-translation.json

As I know that maybe I do not explain well I put an example in code:

It works! $t("Blue")

Doesn't works... ️:S label = "Blue"; $t(label);

If I follow the steps indicated in the official documentation (https://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/translate_theory.html), it does not work either. $t('%1').replace('%1', label);

Someone can help me, please?

Original Report: https://github.com/magento/magento2/issues/16290 by @ekiba