今天又是看到 extension locale 相关的东西,一份用 DTD 表示的本地化字符串文件用于 xml,相对应的一份 resource bundle 文件(.properties),以及 javascript 中使用它时的几个函数 formatStringFromName() 和 GetStringFromName(),但是只搜索到一份 http://www.xulplanet.com/references/xpcomref/ifaces/nsIStringBundle.html 这样的文档,真是郁闷。不知道这是不是唯一的文档,:(
// foxyproxy.js
const CI=Components.interfaces,CC=Components.c lasses,CR=Components.results;
foxyproxy.prototype = {
// ...
strings:
{
_sbs:CC["@mozilla.org/intl/stringbundle; 1"].getService(CI.nsIStringBundleService) .createBundle("chrome://foxyproxy/locale/f oxyproxy.properties"),
_entities:null,
getMessage:function(msg,ar)
{
return ar?this._sbs.formatStringFromName(msg,ar,a r.length):(this._entities[msg]?this._ent ities[msg]:this._sbs.GetStringFromName(m sg));
}
}
// ...
foxyproxy.js 的代码写得很好,以前不知道 javascript 是这样写的,正如不知道自己的 xslt 是不是很土包子一样。
很少遇到需要参数的情况,如果有这种情况,javascript 可以处理,但 DTD 怎么支持它的?..
http://developer.mozilla.org/en/docs/XUL_Tutorial:Localization says: msg.before & msg.after @_@
http://www.mozilla.org/projects/l10n/mlp_tools.html Mozilla Translator 无法访问
http://www.ibm.com/software/globalization IBM 原来有这样一个页面啊.. mugshot 之.