From 7775d0c9c96fec71fdffb1a258cc57ec47d44e66 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Tue, 18 Sep 2018 08:44:47 +0000 Subject: [PATCH] Bug 1491654 - Add lastFallbackLocale at the end of AppLocales. r=jfkthame Differential Revision: https://phabricator.services.mozilla.com/D5985 --HG-- extra : moz-landing-system : lando --- intl/locale/LocaleService.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/intl/locale/LocaleService.cpp b/intl/locale/LocaleService.cpp index 6d91d61bc2b2e..8ec8f8a8c4979 100644 --- a/intl/locale/LocaleService.cpp +++ b/intl/locale/LocaleService.cpp @@ -149,21 +149,21 @@ LocaleService::NegotiateAppLocales(nsTArray& aRetVal) NegotiateLanguages(requestedLocales, availableLocales, defaultLocale, LangNegStrategy::Filtering, aRetVal); - } else { - // In content process, we will not do any language negotiation. - // Instead, the language is set manually by SetAppLocales. - // - // If this method has been called, it means that we did not fire - // SetAppLocales yet (happens during initialization). - // In that case, all we can do is return the default or last fallback locale. - // - // We will return last fallback here, to avoid having to trigger reading - // `update.locale` for default locale. + } + + nsAutoCString lastFallbackLocale; + GetLastFallbackLocale(lastFallbackLocale); + + if (!aRetVal.Contains(lastFallbackLocale)) { + // This part is used in one of the two scenarios: // - // Once SetAppLocales will be called later, it'll fire an event - // allowing callers to update the locale. - nsAutoCString lastFallbackLocale; - GetLastFallbackLocale(lastFallbackLocale); + // a) We're in a client mode, and no locale has been set yet, + // so we need to return last fallback locale temporarily. + // b) We're in a server mode, and the last fallback locale was excluded + // when negotiating against the requested locales. + // Since we currently package it as a last fallback at build + // time, we should also add it at the end of the list at + // runtime. aRetVal.AppendElement(lastFallbackLocale); } }