我正在构建一个 FF 扩展,并且我正在为自己处理一些 xhtml 以支持子表单加载,因此我必须识别定义了 l10n 属性的元素并将它们添加到字符串值。因为 l10n 不能从主代码共享到内容脚本(因为它不是一个简单的 JSON 对象),所以我通过获取加载的键值并定义“本地化数组包”来管理这种情况,如下所示:
lStrings = ["step_title", ........ ];
for (var i = 0; i < lStrings.length; i++) {
bundle[lStrings[i]] = this.locale(lStrings[i]);
}
问题是,我必须在这里写下 .properties 文件中的每个条目......所以,你知道如何访问这个键值吗?我已经尝试使用 .toString .toLocalString 并检查对象,但找不到能够返回所有密钥集合的对象的方式。
你有更好的改进想法吗?