In order to build this CSV app/code/Vendor/Module/i18n/en_US.csv, I want to get an array from my module with all the translation-ready strings from all files types (.php, .phtml, .js, .xml).

.php & .phtml





<group id="general" translate="label" type="text" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1">


<field id="showmethod" translate="label" type="select" sortOrder="280" showInDefault="1" showInWebsite="1" showInStore="0">


<argument name="header" xsi:type="string" translate="true">Report Date</argument>


<item name="label" xsi:type="string" translate="true">CSV</item>


How can I get a list (array) of all the translation-ready strings from a module for creating a CSV file?

1 Answer 1


Magento 2 already has a command that can collect all the texts from a certain folder that are translatable.
Since one module can mean 1 folder, let's say your module name is app/code/Vendor/Module you can collect all translatable texts like this:

bin/magento i18n:collect-phrases app/code/Vendor/Module/ -o app/code/Vendor/Module/i18n/en_US_raw.csv

Just make sure the folder i18n exists inside your module.
After you are done translating what you need to move the file en_US_raw.csv to a file name corresponding to your language code inside the same folder.
For Romanian, for example, the file name should be ro_RO.csv.

  • Hey @Marius, I Update my question, sorry for my first question, I hope so as well now my question.
    – St3phan
    Oct 20, 2017 at 13:56
  • It works perfectly
    – St3phan
    Nov 7, 2017 at 12:40

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.