PDA

View Full Version : about localization



kyousuke
31 Aug 2011, 12:41 AM
version: extjs4
The button's text is still "ok", but when I use a datefield, it show chinese text


<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css">
<script type="text/javascript" src="ext-all.js"></script>
<script type="text/javascript" src="ext-lang-zh_CN.js"></script>
<script>
Ext.onReady(function(){
Ext.MessageBox.alert("SDF", "SDF");
});
</script>

skirtle
31 Aug 2011, 8:55 AM
Agreed. Seems to be a bug. Same for the other locale files too.

Looks like the buttons for the messagebox singleton are created immediately, so the locale file changes the buttonText values too late.

To work round this problem I think you'll have to grab the buttons themselves and change the text directly.

kyousuke
31 Aug 2011, 5:19 PM
Agreed. Seems to be a bug. Same for the other locale files too.

Looks like the buttons for the messagebox singleton are created immediately, so the locale file changes the buttonText values too late.

To work round this problem I think you'll have to grab the buttons themselves and change the text directly.

I found it. It isn't use buttonText to initialize MessageBox, it is use msgButtons.
I changed the locale file like follow. It can work.



if(Ext.MessageBox){
Ext.MessageBox.buttonText = {
ok : "确定",
cancel : "取消",
yes : "是",
no : "否"
};
Ext.MessageBox.msgButtons.ok.text = "确定";
Ext.MessageBox.msgButtons.yes.text = "是";
Ext.MessageBox.msgButtons.cancel.text = "取消";
Ext.MessageBox.msgButtons.no.text = "不";
}

iranphpmaster
24 Oct 2011, 9:08 PM
it work, thank you


I found it. It isn't use buttonText to initialize MessageBox, it is use msgButtons.
I changed the locale file like follow. It can work.



if(Ext.MessageBox){
Ext.MessageBox.buttonText = {
ok : "确定",
cancel : "取消",
yes : "是",
no : "否"
};
Ext.MessageBox.msgButtons.ok.text = "确定";
Ext.MessageBox.msgButtons.yes.text = "是";
Ext.MessageBox.msgButtons.cancel.text = "取消";
Ext.MessageBox.msgButtons.no.text = "不";
}