gecko-dev/intl/locale
Zibi Braniecki cc30b8a270 Bug 1400006 - Extend language negotiation in LocaleService to support looking for the best likelySubtag for the locale with region stripped. r=Pike
Add additional logic to our language negotation to do apply likelySubtags when a direct match is not available.

Currently, if the user specifies the locale with region, and we do not have a direct for that region, we pick all locales for the same language and other regions in no order.

The example of where it returns suboptimal results:

1) Requested locale "en-CA"
2) Available locales ["en-ZA", "en-GB", "en-US"]
3) Negotiated locales ["en-ZA", "en-GB", "en-US"]

This would not happen, if the user requested a generic "de", "en" etc.:

1) Requested locale "en"
2) Available locales ["en-ZA", "en-GB", "en-US"]
3) Negotiated locales ["en-US", "en-ZA", "en-GB"]

because after not finding a direct match, we would use likelySubtags to extend "en" to "en-Latn-US" and then find the priority match in "en-US".

This patch extends this logic to "en-US" or "de-LU" by adding a step which strips the region tag and then applies likelySubtag on the result.

This means that in absence of direct match the following fallbacks would happen:

"de-LU" -> "de-DE"
"es-CL" -> "es-ES"
"en-CA" -> "en-US"

This does not affect languages that use multiple scripts, so ar, sr and zh are not affected.

MozReview-Commit-ID: BR1WrgXSf6a

--HG--
extra : rebase_source : abc205c4f993680ab0cd0c8b8c016543d5462d01
2017-09-14 15:21:33 -07:00
..
android Bug 1384835 (part 3, attempt 2) - Remove the Preferences::Get*CString() variants that return nsAdoptingCString. r=froydnj. 2017-07-31 14:28:48 +10:00
gtk Bug 1380916 - Introduce OSPreferences::GetRegionalPrefsLocales. r=jfkthame 2017-07-13 10:40:40 -07:00
mac Bug 1380916 - Introduce OSPreferences::GetRegionalPrefsLocales. r=jfkthame 2017-07-13 10:40:40 -07:00
tests Bug 1400006 - Extend language negotiation in LocaleService to support looking for the best likelySubtag for the locale with region stripped. r=Pike 2017-09-14 15:21:33 -07:00
unix Bug 1356263 - Remove nsLocaleService, nsILocaleService and ns*Locale APIs. r=m_kato 2017-08-03 02:33:51 -07:00
windows Bug 1356263 - Remove nsLocaleService, nsILocaleService and ns*Locale APIs. r=m_kato 2017-08-03 02:33:51 -07:00
DateTimeFormat.cpp Bug 1379905 - Switch mozIntl, datetimebox and DateTimeFormat to use GetRegionalPrefsLocales. r=jfkthame,smaug 2017-07-14 16:47:23 -07:00
DateTimeFormat.h Bug 1313625 - Remove nsIScriptableDateFormat. r=jfkthame 2017-08-03 16:46:55 +09:00
DateTimeFormatAndroid.cpp Bug 1343766 - Add DateTimeFomat without ICU for Android. r=emk 2017-03-10 12:58:21 +09:00
LocaleService.cpp Bug 1400006 - Extend language negotiation in LocaleService to support looking for the best likelySubtag for the locale with region stripped. r=Pike 2017-09-14 15:21:33 -07:00
LocaleService.h Bug 1400006 - Extend language negotiation in LocaleService to support looking for the best likelySubtag for the locale with region stripped. r=Pike 2017-09-14 15:21:33 -07:00
OSPreferences.cpp Bug 1380916 - Introduce OSPreferences::GetRegionalPrefsLocales. r=jfkthame 2017-07-13 10:40:40 -07:00
OSPreferences.h Bug 1397925 - Refresh OSPreferences mSystemLocales when intl.locale.os changes. r=rnewman 2017-09-07 14:53:36 -07:00
PluralForm.jsm Bug 1048850 - Part 2: make 'ruleNum' an object member to allow the property to be passed to content pages. r=Standard8 2015-11-18 17:09:34 +01:00
encodingsgroups.properties Bug 1369025 - Remove mozilla::dom::EncodingUtils. r=hsivonen 2017-06-17 11:54:40 +09:00
langGroups.properties
language.properties
moz.build Bug 1313625 - Remove nsIScriptableDateFormat. r=jfkthame 2017-08-03 16:46:55 +09:00
mozILocaleService.idl Bug 1379420 - Introduce LocaleService::GetRegionalPrefsLocales. r=jfkthame 2017-07-08 13:54:04 -07:00
mozIOSPreferences.idl Bug 1380916 - Introduce OSPreferences::GetRegionalPrefsLocales. r=jfkthame 2017-07-13 10:40:40 -07:00
nsCollation.cpp Bug 1391628 - Use fallback locale on nsICollation if locale is invalid. r=emk 2017-08-24 23:13:42 +09:00
nsCollation.h Bug 943287 - Part 3. nsICollation fallback version for Android. r=hsivonen 2017-03-23 13:43:38 +09:00
nsCollationAndroid.cpp Bug 1376638 - Minimize uses of prmem.h. r=glandium. 2017-06-30 19:05:41 -07:00
nsCollationCID.h
nsCollationFactory.cpp Bug 943287 - Part 2. Use ICU version of nsICollation on all platform. r=hsivonen 2017-03-23 13:42:49 +09:00
nsCollationFactory.h Bug 1378712 - Remove all trailing whitespaces r=Ehsan 2017-07-06 14:00:35 +02:00
nsICollation.idl Bug 1356263 - Remove nsLocaleService, nsILocaleService and ns*Locale APIs. r=m_kato 2017-08-03 02:33:51 -07:00
nsIPlatformCharset.h Bug 1378712 - Remove all trailing whitespaces r=Ehsan 2017-07-06 14:00:35 +02:00
nsLanguageAtomService.cpp Bug 1394661 - Use user locale instead of system locale for font fallback. r=gandalf 2017-08-30 17:33:12 +09:00
nsLanguageAtomService.h Bug 1373984 - Turn nsIDocument::mCharacterSet into mozilla::NotNull<const mozilla::Encoding*>. r=hsivonen 2017-06-18 20:37:50 +09:00
nsLocaleConstructors.h Bug 1313625 - Remove nsIScriptableDateFormat. r=jfkthame 2017-08-03 16:46:55 +09:00
nsPlatformCharset.h Bug 1351543 - Remove nsIPlatformCharset::GetDefaultCharsetForLocale. r=jfkthame 2017-03-31 10:40:19 +09:00
nsUConvPropertySearch.cpp Bug 1262324 (part 2) - Introduce nsUConvProp. r=emk. 2016-04-06 13:31:38 +10:00
nsUConvPropertySearch.h Bug 1262324 (part 2) - Introduce nsUConvProp. r=emk. 2016-04-06 13:31:38 +10:00
props2arrays.py Bug 1262324 (part 2) - Introduce nsUConvProp. r=emk. 2016-04-06 13:31:38 +10:00