工具 / LocaleUtil
LocaleUtil Class
本地化工具
Table of contents
Methods
getDefaultLocale(): string |
---|
获取默认的语言和地区 |
Methods
getDefaultLocale
• Static
getDefaultLocale(): string
获取默认的语言和地区
Returns
string | 可选ISO 3166-1 国家码 (如, "CN") |
---|
ts
@Component
export default class LocaleExample extends Script {
protected onStart(): void {
if (!SystemUtil.isClient()) return;
this.test();
}
private async test(): `Promise`<`void`\> {
const locale = LocaleUtil.getDefaultLocale();
console.log(`locale: ${locale}`);
// zh-CN
}
}
@Component
export default class LocaleExample extends Script {
protected onStart(): void {
if (!SystemUtil.isClient()) return;
this.test();
}
private async test(): `Promise`<`void`\> {
const locale = LocaleUtil.getDefaultLocale();
console.log(`locale: ${locale}`);
// zh-CN
}
}