如何在Magento 2中安装语言包? [英] How to install a language pack in Magento 2?

查看:468
本文介绍了如何在Magento 2中安装语言包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照 https://mage2.pro/t/topic/270 的说明进行操作a>和 http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-i18n.html#config-cli-subcommands-xlate-example2 但我还是失败了.

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...'

现在,我在app/i18n/Test/de_ch中有以下文件

Right now, I have the following files in app/i18n/Test/de_ch

  • composer.json
  • de_ch.csv
  • language.xml
  • registration.php

此内容包含在 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__);

在管理员中,我使用Deutsch(Schweiz)配置了商店(商店>配置>常规>常规>区域设置选项>区域设置).

In the admin, I configured the store (Stores > Configuration > General > General > Locale Options > Locale) with Deutsch (Schweiz).

然后,尝试对php bin/magento setup:upgrade和php bin/magento cache:clean

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...'

推荐答案

我刚刚尝试过并使其正常运行.您需要进行一些小的大写到小写的更改,反之亦然.

I just tried it and got it working. You need to make few minor uppercase to lowercase changes and vice-versa.

  1. 将文件夹app/i18n/Test/de_ch重命名为app/i18n/test/de_ch(小写t)
  2. 将文件de_ch.csv重命名为de_CH.csv(大写字母CH,这必须与language.xml中的<code></code>相同)
  3. language.xml中,将Test更改为test(当然还将<?xml version="1.0"?>添加到文件的开头).在中定义App/Language/package.xsd
  4. 也在registration.php中将其更改为test_de_ch
  1. Rename folder app/i18n/Test/de_ch to app/i18n/test/de_ch (lowercase t)
  2. Rename file de_ch.csv to de_CH.csv (uppercase CH, this needs to be identical to the <code></code> in language.xml)
  3. In language.xml, change Test to test (of course also add <?xml version="1.0"?> to the beginning of the file). This is defined in App/Language/package.xsd
  4. In registration.php too, change it to test_de_ch

----已编辑以添加完整的代码---

/app/i18n/test/de_ch 创建以下文件:

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__
);

这篇关于如何在Magento 2中安装语言包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆