研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly > setLocale
setLocale() 函数
将语言区域(即本地化消息/块文本等)设置为指定的语言区域。
从脚本标记加载时,这不实用/不必要,因为消息会自动拼接到 Blockly.Msg 对象中。不过,我们同时在脚本标记和非脚本标记环境中提供该标记,以便 tscompiler 正确创建类型定义文件。
Signature:
setLocale: (locale: {
[key: string]: string;
}) => void
参数
参数 |
类型 |
说明 |
语言区域 |
{ [key: string]: string; } |
一个对象,用于定义给定语言的消息。 |
返回:
void
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-04。
[null,null,["最后更新时间 (UTC):2024-11-04。"],[[["The `setLocale()` function sets the locale for Blockly, determining the language used for messages and block text."],["While automatically handled when Blockly is loaded via a script tag, `setLocale()` is crucial for non-script-tag loading and type definition generation."],["It accepts a single argument: an object containing key-value pairs representing the localized messages for the desired language."]]],["The `setLocale()` function sets the localized messages for Blockly. It accepts a `locale` object where keys are strings and values are the corresponding translated messages. This function is primarily used in non-script-tag contexts for setting custom locales. While it's not necessary when using a script tag, it's included for type definition purposes in the TypeScript compiler. The function takes the locale object as the only parameter and doesn't return any value.\n"]]