Question

As far as I understand, there are three steps to adding translations:

  1. collect phrases (bin/magento i18n:collect-phrases ...) to a CSV file that has two columns, e.g., "order","order"
  2. replace the second column with the desired translations (e.g., for German "order","bestellen")
  3. rename the file to e.g., de_DE.csv and put it in the i18n folder of my theme or module

Now, if my module/theme gets updated and new strings are added that I would like to translate, how do I proceed? If I repeat step 1. and collect phrases into the same file, my existing translations will be overwritten.

For WordPress, Poedit allows me to add new translations from a POT file without overwriting previous ones. For Magento, I am not aware of such a tool.

I could of course write a parser that only extracts strings without a translation and adds those to de_DE.csv, but that seems a bit cumbersome - is there a best practices on how to update translation files?

I am aware of question 148062, but I don't find the answer particulary helpful.

Was it helpful?

Solution

I have searched over the web and didn't find something that can solve your problem, but I think such kind of feature will be very useful, so I've written my own solution for this problem: module-translation-helper

you can install it by composer:

composer require underser/module-translation-helper

Install the module and rebuild the DI cache:

./bin/magento setup:upgrade

Then you can collect your new translation by using:

./bin/magento i18n:translation-helper --locale de_DE  --output ./var/de_DE.csv ./app/code/Vendor/NewModule

Note: This is not self-promotion or something like that if you know something better you can always propose your own solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top