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:
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