nsILocaleService

The Locale service interface. This is a singleton object, and should be
obtained from the nsServiceManager.

Methods

newLocale(aLocale)

Create a new nsILocale from a locale string.

Parameters

aLocale A locale code as described in nsILocale.

Returns

A nsILocale representing the given locale.

getSystemLocale()

Get the user preference for locale from the operating system.

Returns

User's OS setting for preferred locale.

getApplicationLocale()

Get 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 etc.). This method returns something
similar to getSystemLocale.

Returns

User's OS setting for preferred locale.

getLocaleFromAcceptLanguage(acceptLanguage)

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

Parameters

acceptLanguage Locale preference in the same format as the Accept-Language HTTP header.

Returns

The most preferred locale according to the acceptLanguage parameter.

getLocaleComponentForUserAgent()

Get 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, but as a string.

Returns

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