mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1336281 followup - Unify the JS-callable and C++-only versions of LocaleService::GetAppLocale, and declare it as a read-only attribute in IDL. r=gandalf
This commit is contained in:
parent
928fbd7db2
commit
2f76f2869c
@ -60,15 +60,6 @@ LocaleService::GetAppLocales(nsTArray<nsCString>& aRetVal)
|
||||
aRetVal = mAppLocales;
|
||||
}
|
||||
|
||||
void
|
||||
LocaleService::GetAppLocale(nsACString& aRetVal)
|
||||
{
|
||||
if (mAppLocales.IsEmpty()) {
|
||||
ReadAppLocales(mAppLocales);
|
||||
}
|
||||
aRetVal = mAppLocales[0];
|
||||
}
|
||||
|
||||
void
|
||||
LocaleService::Refresh()
|
||||
{
|
||||
@ -111,8 +102,11 @@ LocaleService::GetAppLocales(JSContext* aCtx, JS::MutableHandleValue aRetVal)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocaleService::GetAppLocale(JSContext* aCtx, nsACString& aRetVal)
|
||||
LocaleService::GetAppLocale(nsACString& aRetVal)
|
||||
{
|
||||
GetAppLocale(aRetVal);
|
||||
if (mAppLocales.IsEmpty()) {
|
||||
ReadAppLocales(mAppLocales);
|
||||
}
|
||||
aRetVal = mAppLocales[0];
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -57,30 +57,13 @@ public:
|
||||
* Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
|
||||
*
|
||||
* Usage:
|
||||
* nsTArray<nsCString> appLocales;
|
||||
* LocaleService::GetInstance()->GetAppLocales(appLocales);
|
||||
* nsTArray<nsCString> appLocales;
|
||||
* LocaleService::GetInstance()->GetAppLocales(appLocales);
|
||||
*
|
||||
* (See mozILocaleService.idl for a JS-callable version of this.)
|
||||
*/
|
||||
void GetAppLocales(nsTArray<nsCString>& aRetVal);
|
||||
|
||||
/**
|
||||
* Returns the best locale that the application should be localized to.
|
||||
*
|
||||
* The result is a valid locale IDs and it should be
|
||||
* used for all APIs that do not handle language negotiation.
|
||||
*
|
||||
* Where possible, GetAppLocales should be preferred over this API and
|
||||
* all callsites should handle some form of "best effort" language
|
||||
* negotiation to respect user preferences in case the use case does
|
||||
* not have data for the first locale in the list.
|
||||
*
|
||||
* Example: "zh-Hans-HK"
|
||||
*
|
||||
* Usage:
|
||||
* nsAutoCString appLocale;
|
||||
* LocaleService::GetInstance()->GetAppLocale(appLocale);
|
||||
*/
|
||||
void GetAppLocale(nsACString& aRetVal);
|
||||
|
||||
/**
|
||||
* Triggers a refresh of the language negotiation process.
|
||||
*
|
||||
|
@ -16,6 +16,32 @@
|
||||
[scriptable, uuid(C27F8983-B48B-4D1A-92D7-FEB8106F212D)]
|
||||
interface mozILocaleService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns a list of locales that the application should be localized to.
|
||||
*
|
||||
* The result is a sorted list of valid locale IDs and it should be
|
||||
* used for all APIs that accept list of locales, like ECMA402 and L10n APIs.
|
||||
*
|
||||
* This API always returns at least one locale.
|
||||
*
|
||||
* Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
|
||||
*
|
||||
* (See LocaleService.h for a more C++-friendly version of this.)
|
||||
*/
|
||||
[implicit_jscontext] jsval getAppLocales();
|
||||
[implicit_jscontext] ACString getAppLocale();
|
||||
|
||||
/**
|
||||
* Returns the best locale that the application should be localized to.
|
||||
*
|
||||
* The result is a valid locale ID and it should be
|
||||
* used for all APIs that do not handle language negotiation.
|
||||
*
|
||||
* Where possible, getAppLocales() should be preferred over this API and
|
||||
* all callsites should handle some form of "best effort" language
|
||||
* negotiation to respect user preferences in case the use case does
|
||||
* not have data for the first locale in the list.
|
||||
*
|
||||
* Example: "zh-Hans-HK"
|
||||
*/
|
||||
ACString getAppLocale();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user