i18n

国际化扩展的函数。你可以使用这些 api 从与扩展打包在一起的本地化文件中获取本地化字符串,查找浏览器的当前语言,并查找其 Accept-Language header头的值。

有关对扩展使用 i18n 的详细信息,请参阅:

类型

i18n.LanguageCode

一个语言标记 例如 "en-US" 或者 "fr".

方法

i18n.getAcceptLanguages()

得到浏览器 支持的语言 。这与浏览器使用的区域设置不同。要获得区域设置,请使用i18n.getUILanguage.

i18n.getMessage()

获取指定消息的本地化字符串。

i18n.getUILanguage()

获取浏览器的用户界面语言。这与返回首选的用户语言 i18n.getAcceptLanguages 不同。

i18n.detectLanguage()

使用 Compact Language Detector属性检测所提供文本的语言。

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
i18n
LanguageCode
detectLanguage
getAcceptLanguages
getMessage
getUILanguage

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.
Has more compatibility info.

示例扩展

备注: 这个 API 是基于 Chromium 的 chrome.i18n API,这个文档源自 Chromium 代码中的 history.json