OpenSocial小工具应用中的本地化
-
03-07-2019 - |
题
我正在尝试为OpenSocial应用程序添加多语言支持。我看到我可以在小工具XML标记中链接到我自己的消息包:
<Module>
<ModulePrefs title="Hello" description="Message bundle demo">
<Require feature="opensocial-0.7"/>
<Locale lang="en" messages="http://example.com/hello/en_ALL.xml"/>
</ModulePrefs>
. . .
</Module>
但我如何从中提取值?
解决方案
要提取值,您应使用 getMsg 方法
var prefs = new gadgets.Prefs();
var msg = prefs.getMsg('hello_world');
不隶属于 StackOverflow