2

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.

5
  • Not sure that I understand your problem; What about going to previously created de_DE.csv and adding new translations? I mean, why do you need a system which will grab strings to translate for you?
    – underser
    Commented Oct 15, 2019 at 7:50
  • That's a lot of manual work and needs to be done every time I add a module or a template. Even just changing a string would require me to update the CSV file. Other frameworks (like WordPress) automate this process.
    – Daniel
    Commented Oct 15, 2019 at 9:15
  • So now you have ./bin/magento i18n:collect-phrases --magento --output ./var/phrases.csv which collect all phrases, doestn't matter if this phrases been translated before. You need some extra param, like --locale de_DE, it will collect all phrases that not translated for the specified locale. Am I right?
    – underser
    Commented Oct 15, 2019 at 10:05
  • Yes that would be perfect, does something like that exist?
    – Daniel
    Commented Oct 15, 2019 at 10:17
  • Now, I believe, something like that exists. Check my answer, and feel free to ping me if you still have any questions.
    – underser
    Commented Oct 16, 2019 at 14:59

1 Answer 1

3

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

2
  • Wow, fantastic! I'll definitely use that!
    – Daniel
    Commented Oct 21, 2019 at 6:24
  • How does one import back the CSV once translated?
    – Mike
    Commented Jun 24, 2021 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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