How to create a language package for Magento 2
Creating a language package in Magento 2 requires the following steps:
Table of contents
1
Run
For instance:
1 |
./magento i18n:collect-phrases -o "<path to Magento>/app/i18n/df/ru_ru/dictionary.csv" -m "<path to Magento>" |
2
Create an extension for your language package.
2.1
Create a composer.json file.
A core example:
magento/magento2/blob/2.0.0/app/i18n/magento/de_de/composer.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
{ "name": "magento/language-de_de", "description": "German (Germany) language", "version": "100.0.2", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { "magento/framework": "100.0.*" }, "type": "magento2-language", "autoload": { "files": [ "registration.php" ] } } |
The example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "name": "dfl/ru" ,"type": "magento2-language" ,"description": "Russian language" ,"homepage": "https://mage2.pro" ,"license": "proprietary" ,"authors": [{ "name": "Dmitry Fedyuk", "email": "admin@mage2.pro", "homepage": "https://mage2.pro/users/dmitry_fedyuk", "role": "Developer" }] ,"extra": {"map": [["*", "df/ru_ru"]]} } |
2.2
Now, you should create a language.xml file.
magento/magento2/blob/2.0.0/app/i18n/magento/de_de/language.xml
1 2 3 4 5 6 7 8 9 10 11 12 |
<?xml version="1.0"?> <!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>de_DE</code> <vendor>magento</vendor> <package>de_de</package> </language> |
The example
1 2 3 4 5 6 |
<?xml version='1.0'?> <language xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework:App/Language/package.xsd'> <code>ru_RU</code> <vendor>df</vendor> <package>ru_ru</package> </language> |
2.3
Now, it’s time to make a registration.php file.
magento/magento2/blob/2.0.0/app/i18n/magento/de_de/registration.php
1 2 3 4 5 6 7 8 9 10 11 |
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::LANGUAGE, 'magento_de_de', __DIR__ ); |
You can use a
3
Install the extension.
4
Perform the translation and update your module.