nsILocaleService 编辑

intl/locale/idl/nsILocaleService.idlScriptable The Locale service interface. 1.0 66 Introduced Gecko 1.6 Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3)

Implemented by: @mozilla.org/intl/nslocaleservice;1. To use this service, use:

var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
                              .getService(Components.interfaces.nsILocaleService);

 Method overview

nsILocale getApplicationLocale();
AString getLocaleComponentForUserAgent();
nsILocale getLocaleFromAcceptLanguage(in string acceptLanguage);
nsILocale getSystemLocale();
nsILocale newLocale(in AString aLocale);
nsILocale newLocaleObject(in nsILocaleDefinition localeDefinition); Obsolete since Gecko 1.9

Methods

getApplicationLocale()

Gets the user preference for locale from the operating system.

Note: This has nothing to do with the locale used for localization of the application (UI text strings and so on.). This method returns something similar to getSystemLocale.
nsILocale getApplicationLocale();
Parameters

None.

Return value

The user's OS setting for preferred locale.

getLocaleComponentForUserAgent()

Gets the user preference for locale from the operating system.

Note: This has nothing to do with any HTTP User-Agent. This method returns the same as getSystemLocale.getCategory("NSILOCALE_MESSAGES").
AString getLocaleComponentForUserAgent();
Parameters

None.

Return value

The user's OS setting for preferred locale in the format described in nsILocale.

getLocaleFromAcceptLanguage()

Gets the most preferred locale from a list of locale preferences.

nsILocale getLocaleFromAcceptLanguage(
  in string acceptLanguage
);
Parameters
acceptLanguage
Locale preference in the same format as the Accept-Language HTTP header.
Return value

The most preferred locale according to the acceptLanguage parameter.

getSystemLocale()

Gets the user preference for locale from the operating system.

nsILocale getSystemLocale();
Parameters

None.

Return value

The user's OS setting for preferred locale.

newLocale()

Create a new nsILocale from a locale string.

nsILocale newLocale(
  in AString aLocale
);
Parameters
aLocale
A locale code as described in nsILocale.
Return value

A nsILocale representing the given locale.

newLocaleObject()

Obsolete since Gecko 1.9 (Firefox 3)
nsILocale newLocaleObject(
  in nsILocaleDefinition localeDefinition
);
Parameters
localeDefinition
A locale definition as described in nsILocaleDefinition.
Return value

A nsILocale representing the given locale. Calls to its getCategory method return the values originally passed to the locale definition's addCategory method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:83 次

字数:6066

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文