Step 1: collect the phrases
First, you need to find out the phrases that you need to translate.
You can do so by running:
php bin/magento i18n:collect-phrases -o "/path/to/magento2/app/i18n/vendor/lg_lg/dictionary.csv"
Note that vendor
is the same as when you develop module and lg_lg
is the lang code of your language.
Step 2: create the composer.json
file
Go to your app/i18n/vendor/lg_lg
folder and create the composer.json
file:
{
"name": "vendor/lg"
,"type": "magento2-language"
,"description": "Tamil language"
,"authors": [{
"name": "Bilal Usean",
"email": "bla@bla.com",
"role": "Developer"
}]
,"extra": {"map": [["*", "vendor/lg_lg"]]}
}
Step 3: create the language.xml
file
Still in your app/i18n/vendor/lg_lg
folder you need to create a language.xml
file:
<?xml version='1.0'?>
<language xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework:App/Language/package.xsd'>
<code>lg_LG</code>
<vendor>vendor</vendor>
<package>lg_lg</package>
</language>
Step 4: create the registration.php
file
Still in the same folder, you need to create a registration.php
file:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'vendor_lg_lg',
__DIR__
);
Step 5: translate
Still in your folder, you can start writing your translations in a lg_lg.csv
file based on the dictionary you retrieved in step 1. You can use the offical guide to follow the translation guidelines: http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#config-cli-subcommands-xlate-dict-trans
Step 6: create the language pack
Run the following command:
php bin/magento i18n:pack app/i18n/vendor/lg_lg/lg_lg.csv lg_Lg lg_LG
Important note
For this to work, your .csv file name must exactly match the locale, including the characters' case.
Official documentation: http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#config-cli-subcommands-xlate-example2
Best Answer
You can run this command
bin/magento i18n:collect-phrases path/to/extension/folder -o en_US.csv
this will collect all the texts used in the extension in a file called
en_US.csv
that will be located in the root folder of your application (mage_dir).The file will have a set of lines that look like this:
Just replace what's after the comma (second text) with the German version.
Then rename the file to
de_DE.csv
and you can place it inside any extension you have because in Magento2 the translations are not per module anymore. All translation files will be picked up and merged into one big translation cache file used everywhere.