05 本地化模块 - MiEcosystem/miot-plugin-sdk GitHub Wiki
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
-
.language :
string
-
.systemLanguage :
string
-
.timeZone :
string
-
.is24HourTime :
boolean
.getLocation() ⇒[ 'Promise' ].<object>
-
.getSystemTimeZone() ⇒
Promise
-
.language :
-
~ILocale
Kind: inner interface of miot/host/locale
-
~ILocale
-
.language :
string
-
.systemLanguage :
string
-
.timeZone :
string
-
.is24HourTime :
boolean
.getLocation() ⇒[ 'Promise' ].<object>
-
.getSystemTimeZone() ⇒
Promise
-
.language :
获取米家 APP 语言
Kind: instance property of ILocale
获取系统语言
Kind: instance property of ILocale
获取时区
Kind: instance property of ILocale
是否是24小时制计时格式
Kind: instance property of ILocale
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)
})
获取手机的时区信息
Kind: instance method of ILocale
Since: 10024
Example
Host.locale.getSystemTimeZone().then...
result = {"timeZone":"Asia/Shanghai"}