mecodeninja/module-dynamic-translation
最新稳定版本:1.0.0
Composer 安装命令:
composer require mecodeninja/module-dynamic-translation
包简介
N/A
README 文档
README
Magento 2 module that allows a developer to flag rows in translation dictionaries to be added regardless of whether a instance of the string is matched or not.
Install
composer require mecodeninja/module-dynamic-translation
Usage
Append ,dynamic to any translation which should be added to the dictionary (js-translation.json).
Example
en_US.csv
"value1","translated value1",dynamic
"value2","translated value2",dynamic
"value3","value3",dynamic
Results in the following js-translation.json response
{"value1":"translated value1","value2":"translated value2","value3":"value3"}
Scenario
This is helpful if a developer has a value which needs to be translated but the value is part of a dynamic output in a knockout template.
Willwright/Demo/view/frontend/web/template/demo.html
<ul data-bind="foreach: getValues()"> <li> <span data-bind="i18n: $data"></span> </li> </ul>
Willwright/Demo/view/frontend/web/js/demo.js
define(['jquery', 'uiComponent', 'ko'], function ($, Component, ko) { 'use strict'; return Component.extend({ initialize: function () { this._super(); }, getValues: function(){ return [ 'value1', 'value2', 'value3' ]; } }); } );
Normally the above values would not be translated. However, with this module and ,dynamic added to the appropriate
rows the values will be translated.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-07