对于i18n你可以这样
在app文件夹中创建以i18n命名的文件夹
在i18n 文件夹中创建与主题相同的子文件夹,例如custom
在i18n -> custom 文件夹中创建语言包文件夹,如en_us 或en_gb
现在您的文件夹结构将像这样app/i18n/custom/en_us/
现在在这个你的语言包文件夹中制作以下文件,所有文件都将在这个文件夹结构中app/i18n/custom/en_us/
app/i18n/custom/en_us/composer.json
{
"name": "custom/en_us",
"description": "English (US) language",
"version": "100.0.1",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*"
},
"type": "magento2-language",
"autoload": {
"files": [
"registration.php"
]
}
}
app/i18n/custom/en_us/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>en_US</code>
<vendor>custom</vendor>
<package>en_us</package>
</language>
app/i18n/custom/en_us/registration.php
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::LANGUAGE,
'custom_en_us',
__DIR__
);
之后,将您的 en_US.csv 放入您的语言包文件夹中
- app/i18n/custom/en_us/en_US.csv
在运行以下命令之后
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
-
php bin/magento cache:clean
希望对你有帮助