Translation string, how to
-
04-10-2020 - |
Domanda
When translating a line in, for example, this path to the file the line is in:
vendor/magento/module-checkout/view/fontend/web/template/shipping-information.html
This will be the translation line:
"Example String","Voorbeeld String","module","Magento_Checkout"
But what if this is the path:
vendor/tig/buckaroo/view/frontend/web/template/payment/tig_buckaroo_ideal.html
What is the translation string in that case?
In my case, I want to translate "Select your bank" to "Selecteer uw bank". Normally, the format would be like this:
vendor/STORE/TYPE-LOCATION/etc....
And it would be added to the translation file like this:
"Select your bank","Selecteer uw bank","TYPE","STORE_LOCATION"
But, in this case, it is very different, because the path is not the default format for translating.
Soluzione
Create your translate (en_US.csv)file in below path :
/{magento 2 root folder}/app/design/frontend/{Vendor}/{theme name}/i18n/en_US.csv
Now add your translations in above created file.
Altri suggerimenti
When dealing with translations best way is to start with collecting translatable phrases, you can do so by issuing following command:
bin/magento i18n:collect-phrases --output "app/i18n/Vendorname/nl_NL.csv" --magento
This will collect all translatable phrases including ones from Modules in specified csv file along with their location.
Now you can find and replace (second instance only) ones which you want to translate and for house keeping get rid of the rest or leave them in, they do no harm. For example after issuing above command in my csv I see:
"Add New Banner","Add A Banner",module,Lof_Gallery
Where Add New Banner is translatable phrase of module Lof Gallery and I changed it to Add A Banner
Once finished translating issue coomand:
bin/magento i18n:pack app/i18n/Vendorname/nl_NL.csv -d nl_NL
This will deploy your translations to related modules. Clear cache and all that and it should work.