magento2: Translation in html files using $t() broken?
I use beta4 and switched the store language to de_DE. While many strings are just not yet translated to DE, there is a translation in app/code/Magento/Checkout/i18n/de_DE.csv for example for
"Shipping Address",Lieferungsadresse
If I am getting it correctly, this is referenced in app/code/Magento/Checkout/view/frontend/web/template/shipping.html:8
<div class="step-title" data-bind="text: $t('Shipping Address')" data-role="title"></div>
But still the English text is shown.
Is the Javascript translation currently broken?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 47 (17 by maintainers)
This is still an issue I have
data-bind="text: isVirtual ? $t('Enter your billing address to get a tax estimate.') : $t('Enter your destination to get a delivery estimate.')"which does not get added to a CSV when runningcollect-phrasesand trying to manually translate it doesn’t work.Workaround, tested in magento 2.2.6
Copy the file: vendor/magento/module-checkout/view/frontend/web/template/cart/shipping-estimation.html
To your theme: app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Checkout/web/template/cart/shipping-estimation.html
Then the strings are going to be translated:
$t(‘Estimate Tax’) $t(‘Estimate Shipping and Tax’) $t(‘Enter your billing address to get a tax estimate.’) $t(‘Enter your destination to get a shipping estimate.’)
Tried all solutions in this thread and others on the internet without solving the issue with
$t()not working. My frontendjs-translation.jsonis empty (located atpub/static/frontend/<Vendor>/<theme>/sv_SE/js-translation.jsoneven though I have non-empty translations at/app/i18n/magento/sv_se/sv_SE.csvand/app/design/frontend/<Vendor>/<theme>/i18n/sv_SE.csvthat works on PHP level, I clear caches withbin/magento cache:cleanandbin/magento cache:flushandfind pub/static -name js-translation.json -exec rm -rf {} \;and runbin/magento setup:static-content:deploy sv_SEon latest Magento2.1.2.I did not followup this. But I checked the js-translate.json and it looked good. I can currently use develop, because I use composer and do not want to mess with that process at the moment. I hope there will soon be another composer release?