替换Dojo / Dijit NLS字符串 [英] Replacing Dojo/Dijit NLS strings

查看:94
本文介绍了替换Dojo / Dijit NLS字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想覆盖一个NLS文件(dijit / form / validate.js)文件,或者替换一些NLS字符串映射。我想要这个文件被标准的Dijits所取代。



我不希望删除标准Dojo库中的文件。我可以在djConfig中指定一个路径来搜索NLS文件的目录,以便我的新文件被取代而不是原始文件?如果是这样,我该怎么做?



或者,我如何混合一个新的字符串定义,即



替换:

  missingMessage:此值是必需的,
/ pre>

with:

  missingMessage:我的字符串在这里。,


解决方案

如果你想按照你要求的方式,并为 dijit / form / nls / validate i18n模块选择一个备用文件,你可以使用 map 属性重新映射模块ID(1.8 +):

  var dojoConfig = {
map:{dijit: {
'dijit / form / nls / validate':'my / form / nls / validate',
'dijit / form / nls / en / validate'验证',
// ...等
}}
};

但是,用于覆盖验证窗口小部件上的消息的标准和推荐方法只是设置消息属性使用您自己的值:

  define([
'dijit / form / ValidationTextBox ',
'dojo / i18n!my / form / validate'
],function(ValidationTextBox,myI18n){
var instance = new ValidationTextBox({missingMessage:myI18n.missingMessage});
// ...
});


I wish to override a NLS file (dijit/form/validate.js) file with a new one, or replace some of the NLS string mappings. I want this file to be picked up by the standard Dijits.

I do not wish to delete the file in the standard Dojo library. Can I specify a path in djConfig to search directories for NLS files in order so my new file is picked up instead of the the original? If so, how do I do this?

Alternatively how can I mix in a new definition of a string i.e

replace:

missingMessage: "This value is required.",

with:

missingMessage: "My string is here.",

解决方案

If you want to do literally what you request and pick an alternate file for the dijit/form/nls/validate i18n modules, you can use the map property to remap the module IDs (1.8+):

var dojoConfig = {
    map: { dijit: {
        'dijit/form/nls/validate': 'my/form/nls/validate',
        'dijit/form/nls/en/validate': 'my/form/nls/en/validate',
        // ... etc
    } }
};

However, the standard and recommended method for overriding the messages on a validation widget are to just set the message properties using your own values:

define([
    'dijit/form/ValidationTextBox',
    'dojo/i18n!my/form/validate'
], function (ValidationTextBox, myI18n) {
    var instance = new ValidationTextBox({ missingMessage: myI18n.missingMessage });
    // ...
});

这篇关于替换Dojo / Dijit NLS字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆