Dojo自定义语言变体 [英] Dojo custom language variants
问题描述
有没有人知道我是否能够为Dojo的自定义语言变体创建与i18n一起使用的区域设置
示例
define({
root:{
greeting:你好,世界!
}
de-myVariant:true
});
是的,可以做到。如果您有 nls / SampleApp.js
as:
define({
root:{
greeting:你好!
}
de:true,
de-at:true,
de -x-mundl:true
});
那么在 nls下有三个子目录
:
nls / de
nls / de-at
nls / de-x-mundl
for nls / de / SampleApp.js
:
define(({
greeting:Hallo!
}));
for nls / de-at / SampleApp.js
:
define(({
greeting:GrußGott!
}));
和 nls / de-x-mundl / SampleApp.js
:
define(({
greeting:Servus,Mundi!
}));
然后,如果您配置Dojo以将该区域设置为URL参数:
< script src =./ dojo / 1.8.3 / dojo / dojo.js
data-dojo-config =locale: location.search.substring(1).toLowerCase()>
< / script>
您可以通过传递语言环境标记作为参数来轻松切换语言:
... / app.html?de-DE
... / app.html?de-at
.. ./app.html?de-x-Mundl
请注意,Dojo将区域设置标签视为区分大小写这就是为什么输入是 toLowerCase()
ed,内部所有的标签都保持小写。
Does Dojo support creation of custom language variants to be used for with Dojo's locale and i18n
Does anyone know if I am able to create a custom language variant for Dojo's locale that works with i18n?.
Example
define({
root: {
greeting: "Hello, world!"
}
"de-myVariant" : true
});
Yes, it can be done. If you have nls/SampleApp.js
as:
define({
root: {
greeting: "Hello!"
}
"de" : true,
"de-at": true,
"de-x-mundl": true
});
then there would be three sub-directories under nls
:
nls/de
nls/de-at
nls/de-x-mundl
for nls/de/SampleApp.js
:
define(({
greeting: "Hallo!"
}));
for nls/de-at/SampleApp.js
:
define(({
greeting: "Gruß Gott!"
}));
and for nls/de-x-mundl/SampleApp.js
:
define(({
greeting: "Servus, Mundi!"
}));
Then if you config Dojo to get the locale as a URL parameter:
<script src="./dojo/1.8.3/dojo/dojo.js"
data-dojo-config="locale: location.search.substring(1).toLowerCase()">
</script>
you can switch the language easily by passing the locale tag as that parameter:
.../app.html?de-DE
.../app.html?de-at
.../app.html?de-x-Mundl
Note that Dojo considers locale tags as case-sensitive and that's why the input is toLowerCase()
ed and internally all the tags are kept in lower-case.
这篇关于Dojo自定义语言变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!