MindSphere Web Components
国际化
MindSphere Web 组件通过 local
属性支持不同的区域。组件默认提供区域 en
和 de
并允许开发者使用 localeManager
添加或修改区域。
localeManager
提供了以下方法来读取、覆盖或定义 MindSphere Web 组件新的 i18n 文本:
内容 | 描述 |
---|---|
getLocaleSettings(): any | 返回组件的区域设置。使用此方法来确定可翻译文本并检查组件的当前区域设置。 |
addLocale(LocaleName: string, settings: any) | 定义一个新的区域并提供带有翻译文本的对象。 |
信息
区域属性对所有 MindSphere Web 组件适用,但一些组件(例如:地图)不包含任何可翻译文本。
片段
改变默认区域设置
```javascript tab="German" // displays the component in German ruleComp.locale = "de";
```javascript tab="English"
// displays the component in English
ruleComp.locale = "en";
创建新区域设置
在下面的例子中,为 asset 视图定义了一个新的语言区域 fr
,并用法语覆盖了 search
文本。
// check the locale setting of the component
var currentLocale = assetViewComp.localeManager.getLocaleSettings();
// replace the text for "search" with the french word
var frLocale = { search: "recherche" };
// create a new locale "fr" with the updated translation
assetViewComp.localeManager.addLocale("fr", frLocale);
// change the view to the new locale
assetViewComp.locale = "fr";
还有问题?
除非另行声明,该网站内容遵循MindSphere开发许可协议.
Last update: April 1, 2020