How to install a language pack in Magento 2?
Solution 1
I just tried it and got it working. You need to make few minor uppercase to lowercase changes and vice-versa.
- Rename folder
app/i18n/Test/de_ch
toapp/i18n/test/de_ch
(lowercase t) - Rename file
de_ch.csv
tode_CH.csv
(uppercase CH, this needs to be identical to the<code></code>
inlanguage.xml
) - In
language.xml
, changeTest
totest
(of course also add<?xml version="1.0"?>
to the beginning of the file). This is defined in App/Language/package.xsd - In
registration.php
too, change it totest_de_ch
---- edited to add complete code ---
In /app/i18n/test/de_ch
Create the following files:
composer.json
{
"name": "test/de_ch",
"description": "German (Switzerland) language",
"version": "100.0.1",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*"
},
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}
de_CH.csv
"Search entire store here...","Suche TESTING..."
language.xml
<?xml version="1.0"?>
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
<code>de_CH</code>
<vendor>test</vendor>
<package>de_ch</package>
</language>
registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'test_de_ch',
__DIR__
);
Solution 2
You can buy it and install it :)
composer config repositories.atconnect composer https://connect20.aveo-trade.cz
composer require atconnect/magento-two-language-de-de
We use this composer package structure: magento-two-language-de-de/composer.json
{
"name": "atconnect/magento-two-language-de-de",
"description": "Magento 2.0.0: de_DE",
"version": "2.0.0.2-stable",
"license": [
"proprietary"
],
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}
magento-two-language-de-de/language.xml
<?xml version="1.0"?>
<!--
/**
* @copyright Copyright (c) AveoTrade
Licence: https://connect20.aveo-trade.cz/cat:Agreement
*/
-->
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd">
<code>de_DE</code>
<vendor>atconnect</vendor>
<package>magento-two-language-de-de</package>
</language>
magento-two-language-de-de/registration.php
<?php
/**
* Copyright © 2015 AveoTrade
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'atconnect_magento-two-language-de-de',
__DIR__
);
magento-two-language-de-de/de_DE.csv
"1 Hour","1 Stunde",module,Magento_AdminNotification
"12 Hours","12 Stunden",module,Magento_AdminNotification
"2 Hours","2 Stunden",module,Magento_AdminNotification
"24 Hours","24 Stunden",module,Magento_AdminNotification
"6 Hours","6 Stunden",module,Magento_AdminNotification
Related videos on Youtube
Henry
Updated on June 29, 2022Comments
-
Henry almost 2 years
I tried to follow the instructions from https://mage2.pro/t/topic/270 and http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#config-cli-subcommands-xlate-example2 but I still failed.
I'm trying to change the text of the search box in the header from 'Search entire store here...' to 'Suche...'
Right now, I have the following files in app/i18n/Test/de_ch
- composer.json
- de_ch.csv
- language.xml
- registration.php
With this content in composer.json
{ "name": "test/de_ch", "description": "German (Switzerland) language", "version": "100.0.1", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { "magento/framework": "100.0.*" }, "type": "magento2-language", "autoload": { "files": [ "registration.php" ] } }
de_ch.csv
"Search entire store here...","Suche..."
language.xml
<language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>de_CH</code> <vendor>Test</vendor> <package>de_ch</package> </language>
registration.php
<?php \Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,'Test_de_ch',__DIR__);
In the admin, I configured the store (Stores > Configuration > General > General > Locale Options > Locale) with Deutsch (Schweiz).
Then, tried to php bin/magento setup:upgrade and php bin/magento cache:clean
But nothing, the text in the Search form is still 'Search entire store here...'
-
Henry over 8 yearsTried it, then saw that it started with "Requested language: en_US". When finished, the translation was still not working. So I tried php bin/magento setup:static-content:deploy de_CH. The command succeeded but I still can't see the translation.
-
Henry over 8 yearsGreat, it works now! You could post the whole code to help the others :)
-
Steve Johnson over 8 yearsYes, we updated documentation yesterday. Sorry about the capitalization errors. Please let us know if you find issues with the topic now.
-
Henry over 8 yearsHello Scholtz, I bought your extension, but it asks for a user and password when I "composer update". What should I provide?
-
Scholtz over 8 yearsHi, already wrote you back the email, but i will reply also here.. Make sure that you have set your api key for the purchased extension, and the api key name is username and api key secret is the password. connect20.aveo-trade.cz/cat:ApiKey
-
LucScu about 7 yearsYes it works, but how is possible override it? i create app/design/Theme/default/i18n/xx_XX.csv, but it not override, so i can't add customizations if not in original csv.
-
Maddy about 7 years@LucaS this example is for a stand alone language pack. instruction for language embedded within a theme will be different.
-
LucScu about 7 years@Maddy i think your reply is out of scope, maybe my question is not clear. So, how is possible override stand alone language pack? I don't want change original stand alone language pack, i will lose changes when update it, so i have to extend it. Are you agree?
-
matinict about 6 yearsnot work for me show error [InvalidArgumentException] ku_IQ argument has invalid value, please run info:language:list for list of available locales