Magento – Magento 2: The command bin/magento i18n:collect-phrases does not work

magento2

I am having trouble using the magento i18n:collect-phrases command to collect phrases for translation.

When I use:

php bin/magento i18n:collect-phrases -o
"/app/i18n/test/xx_YY/dictionary.csv" -m

I get the error message:

[RuntimeException] Not enough arguments

When I try to specify a location where to find phrases:

php bin/magento i18n:collect-phrases -o
"/app/i18n/test/xx_YY/dictionary.csv" /vendor/magento

I get the error message: [InvalidArgumentException] Specified path doesn't exist

I get the same message (Specified path doesn't exist) whichever path I chance the last part of the command into (app/design/frontend…. etc).

I took one csv file from one of the module categories, translated that into my language and tried to upload it using

php bin/magento setup:static-content:deploy 

This worked and showed translation on the frontend as well. But it doesn't have all the phrases and if I add phrases to that file manually, it does not show those phrases on the storefront.

The website that uses Magento is an addon domain, so the server category structure is:

/home/Maindomain/addondomain/app, bin etc.

Could this be the reason why I am not able to collect phrases for translation?

Any help would be greatly appreciated.

Best Answer

Your file /app/i18n/test/xx_YY/dictionary.csv should be have four columns

  1. The value of Translate
  2. The value should be translated with this.
  3. Module used simply module
  4. Module Name of that particular translator e.g. Magento_Catalog

e.g

Save Category Save Category New module Magento_Catalog

AND

[InvalidArgumentException] Specified path doesn't exist

for this, you have to collect translate variable from Magento2 Root

use

php bin/magento i18n:collect-phrases -o "/app/i18n/test/xx_YY/dictionary.csv" Magento2ROOT/

instead of

php bin/magento i18n:collect-phrases -o "/app/i18n/test/xx_YY/dictionary.csv" /vendor/magento

it will help you.