浏览文章
文章信息
Magento2语言包制作翻译|How to translate Magento2 by language pack
14536
1、收集翻译短语
bin/magento i18n:collect-phrases -o "/www/wwwroot/www.demo.com/app/i18n/Vendor/zh_Hans_CN.csv" -m将文件翻译后执行第二步,
vendor是可替换的目录,一般表示公司名
2、创建语言包(使用语言包)
bin/magento i18n:pack /www/wwwroot/www.demo.com/app/i18n/Vendor/zh_Hans_CN.csv -d zh_Hans_CN3、部署语言包静态资源
bin/magento setup:static-content:deploy -f zh_Hans_CN4、刷新缓存
bin/magento cache:clean
至此,语言包翻译magento语言完成!
温馨提示:如果需要发布语言包作品的,请继续往下看!
在该目录中,添加以下所有内容:
- 许可证,如果需要的话
composer.json
(以下样本)registration.php
(以下样本)language.xml
(以下样本)样品
composer.json
:{ "name": "examplecorp/language-xx_yy", "description": "Sample language", "version": "100.0.2", "license": [ "OSL-3.0", "AFL-3.0" ], "require": { "magento/framework": "100.0.*" }, "type": "magento2-language", "autoload": { "files": [ "registration.php" ] }}样品
registration.php
:/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ use \Magento\Framework\Component\ComponentRegistrar; ComponentRegistrar::register(ComponentRegistrar::LANGUAGE, 'magento_xx_yy', __DIR__);样品
language.xml
:<?xml version="1.0"?><!-- /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --><language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>xx_YY</code> <vendor>examplecorp</vendor> <package>xx_yy</package></language>