custom language package not working
-
22-01-2021 - |
Question
Since the German translation of "Grid" within the german language pack is currently wrong (see here), I wanted to override it using a custom language pack (since you cannot override translations of translation packages within a module or a theme). I used the instructions provided here and also looked at the documentation.
This is what I have so far:
app/code/InspiredMinds/language-de_de/registration.php
:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'InspiredMinds_de_de',
__DIR__
);
app/code/InspiredMinds/language-de_de/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_DE</code>
<vendor>InspiredMinds</vendor>
<package>de_de</package>
<use vendor="mageplaza" package="de_de" />
</language>
app/code/InspiredMinds/language-de_de/de_DE.csv
:
"Grid","Raster",module,Magento_Catalog
Instead of
app/code/InspiredMinds/language-de_de
I also tried
app/i18n/InspiredMinds/de_de
I cleaned all caches and also ran a setup:di:compile
(in case that is necessary for language packs). It still does not work.
What am I missing?
Solution
As mentioned/suspected by @steros, there seems to be a bug with language packs regarding upper case letters within the component name. As far as I tested, the $componentName
within registration.php
must not contain uppercase letters (to fit the actual vendor and package name for example).
My above code works within
app/i18n/InspiredMinds/de_de
when I use all lower case letters as the component name in the registration.php
:
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'inspiredminds_de_de',
__DIR__
);
Everything else can stay in camel cases.
OTHER TIPS
Put everything in:
app/i18n/inspiredminds/de_de
registration:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'inspiredminds_de_de',
__DIR__
);
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_DE</code>
<vendor>Inspiredminds</vendor>
<package>de_DE</package>
<use vendor="magento" package="en_us" />
</language>
name your csv file de_DE.csv
.
You need to run magento setup:static-content:deploy de_DE
too depending on your setup.