Arj*_*jan 7 translation i18next
我想用i18next格式化嵌套翻译
鉴于资源:
{"translation":{
"en":{
"food" : "bread",
"food_is_good" : "$t(food), that's not bad"
}
}
Run Code Online (Sandbox Code Playgroud)
和格式化功能:
function format(value, format, lng) {
if (value==undefined) return value;
switch (format) {
case 'capitalize': return _.capitalize(value);
default : return value;
}
}
Run Code Online (Sandbox Code Playgroud)
用于i18next的初始化:
...
interpolation: { format: format },
...
Run Code Online (Sandbox Code Playgroud)
我希望输出为“面包,那还不错”。所以我希望像这样:
{
...
"food_is_good_1" : "$t(food,capitalize), that's not bad",
"food_is_good_2" : "{{$t(food),capitalize}}, that's not bad",
"food_is_good_3" : "{{food,capitalize}}, that's not bad",
...
}
Run Code Online (Sandbox Code Playgroud)
会成功的 第一个选项显示错误:"failed parsing options string in nesting"
后两个选项警告:missed to pass in variable food,capitalize for interpolating {{food,capitalize}}
| 归档时间: |
|
| 查看次数: |
457 次 |
| 最近记录: |