Bug 1409973 - Update JS runtime default locale when pref javascript.use_us_english_local changes. r=Gijs

MozReview-Commit-ID: GzKSIFEqw4h

--HG--
extra : rebase_source : 847699aa3cab73c631103f865e849d2d27553b84
This commit is contained in:
Chung-Sheng Fu 2018-01-15 17:15:22 +08:00
Родитель f5f54cbc54
Коммит cd3aaede6c
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -43,12 +43,15 @@ XPCLocaleObserver::Init()
mozilla::services::GetObserverService();
observerService->AddObserver(this, "intl:app-locales-changed", false);
Preferences::AddStrongObserver(this, "javascript.use_us_english_locale");
}
NS_IMETHODIMP
XPCLocaleObserver::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
{
if (!strcmp(aTopic, "intl:app-locales-changed")) {
if (!strcmp(aTopic, "intl:app-locales-changed") ||
(!strcmp(aTopic, "nsPref:changed") && !NS_strcmp(aData, u"javascript.use_us_english_locale"))) {
JSRuntime* rt = CycleCollectedJSRuntime::Get()->Runtime();
if (!xpc_LocalizeRuntime(rt)) {
return NS_ERROR_OUT_OF_MEMORY;