`

怎么用properties

阅读更多

转自:http://zhongzhihua.iteye.com/blog/77772

 

 

一,先在xul文件中写上

xml 代码

  1. < stringbundle   id = "bundle_prefs"   src = "chrome://messenger/locale/prefs.properties" />   

 

<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"></stringbundle>
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"></stringbundle>
<stringbundle id="bundle_prefs" src="chrome://messenger/locale/prefs.properties"></stringbundle>

再prefs.properties中写上这想写的中文字,如failedDuplicateAccount = 复制此帐户失败。

再js中的写一个全局变量如:var gPrefsBundle ,再 onload()中加载它 gPrefsBundle = document.getElementById("bundle_prefs");现在这个gPrefsBundle 变量就是prefs.properties文件了,你想得到"复制此帐户失败。" 这句话只要

var alertText = gPrefsBundle.getString("failedDuplicateAccount");
        window.alert(alertText);

这样就可以打印出"复制此帐户失败";

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics