05 本地化模块 - MiEcosystem/miot-plugin-sdk GitHub Wiki

miot/host/locale

host 的本地信息, 包括语言,时区和地理位置

Export: public
Doc_name: 本地化模块
Doc_index: 5
Doc_directory: host
Example

import {Host} from 'miot'
...
let language = Host.locale.language
let timeZone = Host.locale.timeZone
if (language === 'zh') ...
...

miot/host/locale~ILocale

Kind: inner interface of miot/host/locale


iLocale.language : string

获取米家 APP 语言

Kind: instance property of ILocale


iLocale.systemLanguage : string

获取系统语言

Kind: instance property of ILocale


iLocale.timeZone : string

获取时区

Kind: instance property of ILocale


iLocale.is24HourTime : boolean

是否是24小时制计时格式

Kind: instance property of ILocale


iLocale.getLocation() ⇒ [ 'Promise' ].<object>

Deprecated

获取手机地理位置信息

Kind: instance method of ILocale
Returns: [ 'Promise' ].<object> - { country province city district(区域) street address latitude(纬度) longitude(经度) citycode(城市编码) adcode(区域编码) }
Example

import {Host} from 'miot'
...
Host.locale.getLocation().then(res => {
 console.log('get location: ', res)
})

iLocale.getSystemTimeZone() ⇒ Promise

获取手机的时区信息

Kind: instance method of ILocale
Since: 10024
Example

Host.locale.getSystemTimeZone().then...
result = {"timeZone":"Asia/Shanghai"}

⚠️ **GitHub.com Fallback** ⚠️