0

I want to translate a variable in Knockout

<span id="sales_unit" data-bind="i18n:sales_unit"></span>

sales_unit has the value pair. The value should be translated to a different language


Actual Result:

<span id="sales_unit" data-bind="i18n:sales_unit">pair</span>

Target Result:

<span id="sales_unit" data-bind="i18n:sales_unit">pár</span>

It only will translate correctly, if i add the result string in knockout once

<span id="sales_unit_pair" data-bind="i18n:'pair'" style="display:none"></span>

If I delete this line afterwards, the translation magicaly works from now on, until i clear the cache.

This is not really a pretty solution and is only a workaround. Does anybody know, how i can fix this?

0

Did you re-deploy everything by locale/language too?

You need to add the CSV file with your translations in the language folder i18n inside your theme. Here are the details explained better: https://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/xlate.html

Try to not override directly the Ko templates values, that could make strange behavior in some cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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