如何在 WebO 中设置默认语言

发布于 2024-08-16 08:23:57 字数 266 浏览 1 评论 0原文

如何设置WebOs项目的默认语言? 在 WebOS 中添加国际化的标准方法是使用 $L() 函数,我可以在其中为翻译后的字符串设置一个键。但是,如果项目中未指定当前语言,WebOS 会向用户显示密钥。我怎样才能停止这种行为并设置默认语言,它将代替密钥。

PS:我认为 Palm 获取现实世界句子的方式并不是一种好的编程方式。

错误示例:$L(“这不应该是现实世界的句子!!”)
更好的例子:$L("key.subKey")

How can I set the dault language of an WebOs project?
The standard way of adding internationalization in WebOS is to use the $L() function, where I can set a key to the translated string. But if the current language ist not specified in the project WebOS displays the key to the user. How can I stopp this behaviour and set a default language, that will be taken instead of the key.

PS: I think the Palm way of taking a real world sentences is not a good way of programming.

Bad example: $L("This should be not a real world sentence!!")
Better example: $L("key.subKey")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖阳 2024-08-23 08:23:57

您可以使用键值对来解决此问题(来自 Palm 文档):

如果原始字符串不适合作为键,则可以使用显式键调用 $L() 函数:

$L("value":"完成", "key": "done_key");

在运行时,调用 $L() 的结果是作为值传递的字符串的翻译。翻译在 /resources/locale/strings.json 文件中“实时”。

示例:
文件 app_name/resources/es_us/strings.json 的内容:

{

"我的文字在这里": "Mi texto aquí",
"done_key": "列表",
"Some other string": "其他一些字符串的翻译"

}

You can use a key-value pair to solve this problem (from the Palm documentation):

If the original string is not appropriate as a key, the $L() function can be called with an explicit key:

$L("value":"Done", "key": "done_key");

At run-time, the result of the call to $L() is the translation of the string passed as value. The translations "live" in the /resources/locale/strings.json file.

Example:
content of file app_name/resources/es_us/strings.json:

{

"My text here": "Mi texto aquí",
"done_key": "Listo",
"Some other string": "Some other string's translation"

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文