This blog explains how to create language package on Magento 2. Here's the example of Vietnamese language.
1. Generate dictionary file
$ cd /root/dir/magento
$ bin/magento i18n:collect-phrases --output="app/design/frontend/vendor_name/theme_name/i18n/vi_VN.csv" --magento ./
2. Create language pack and register it
$ bin/magento i18n:pack -d app/design/frontend/app_name/theme_name/i18n/vi_VN.csv ./ vi_VN
3. Modify config files
Add & modify these 3 files.
# app/i18n/app_name/vi_VN/composer.json
{
"name": "app_name/language-vi_vn",
"description": "Vietnamese language",
"version": "100.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*"
},
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}
# app/i18n/app_name/vi_VN/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'magento_vi_vn',
__DIR__
);
# app/i18n/app_name/vi_VN/language.xml
# PLEASE NOTICE MANUAL IS WRONG
# package MUST BE LOWER CASE
<?xml version="1.0"?>
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
<code>vi_VN</code>
<vendor>app_name</vendor>
<package>vi_vn</package>
<sort_order>100</sort_order>
</language>
Reference
http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#m2devgde-xlate-files
If you liked this article
Let's subscribe the updates of Scuti!
This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
Please help.
ReplyDeleteAfter refresh frondend I get an error as the following:
Notice: Undefined offset: 1 in /var/www/html/megamart/vendor/magento/framework/App/Language/Dictionary.php on line 183
What was happening ? Thanks
I can't give you exact answer with only this information but CSV format is correct? I see this person also encountered the same problem.
Deletehttp://magento.stackexchange.com/questions/101692/problem-when-create-a-language-package-for-magento-2
I might want to thank you for the endeavors you have made in composing this article. I am trusting the same best work from you later on too.. Magento extensions by Mageworx
ReplyDeleteThat is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
ReplyDeleteMagento course in chennai