문제

I can translate strings in Knockout html templates like this:

<!-- ko i18n: 'Email' --><!-- /ko -->
<span data-bind="i18n: 'Email'"></span>

And the translations come from pub/static/<area>/<vendor>/<theme>/xx_XX/js-translation.json.

But I do not know how to translate a value in an HTML attribute, e.g. the placeholder attribute on an input tag, like

<input type="text" placeholder="Email" />
도움이 되었습니까?

해결책

You can write like this

<input type="text" data-bind="attr:{placeholder: $t('Email')} " />

Run below commands

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top