我有一个自定义语言文件:
Ext.define('DemoApp.util.Resource' {
singleton: true,
text: 'English'
});
var R = DemoApp.util.Resource;
现在我有了另一个自定义语言文件:
Ext.define('DemoApp.util.fr.Resource' {
override: 'DemoApp.util.Resource',
text: 'French'
});
在Application.js:中
init: function() {
var url;
url = Ext.util.Format.format("locale/util/fr/Resource.js");
Ext.Loader.loadScript({
url: url,
scope: this
});
},
在视图中我使用:
items: [{
xtype: 'button',
text: R.text
}]
它加载"English",但如果我在Ext.Msg.show中放入R.text,它就会加载"French"。
也许它在视图渲染后加载js文件。如何在视图渲染之前加载它?我试过Ext.apply,它也不起作用。
非常感谢!
我不知道你的代码是什么,但在Fiddle中,它首先显示"English",然后显示"French":
Ext.define('DemoApp.util.Resource', {
//singleton: true, // makes an error in fiddle
text: 'English'
});
Ext.application({
name : 'Fiddle',
launch : function() {
var R = Ext.create('DemoApp.util.Resource');
alert(R.text);
Ext.define('DemoApp.util.fr.Resource', {
override: 'DemoApp.util.Resource',
text: 'French'
});
alert(R.text);
}
});
备注:注意Ext.define
功能中的昏迷。