gecko-dev/intl/locale/tests/unit
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
..
data Bug 1174386 - Make workers inherit the default Intl locale from the main thread, rather than using a bogus fallback value. r=jwalden, r=baku 2016-08-08 13:33:39 -07:00
test_bug22310.js Bug 1301655 - pt 9 - Update test_bug22310.js to remove use of nsIScriptableDateFormat. r=gandalf 2016-10-28 12:04:07 +01:00
test_bug1086527.js
test_collation.js Bug 943287 - Part 2. Use ICU version of nsICollation on all platform. r=hsivonen 2017-03-23 13:42:49 +09:00
test_intl_on_workers.js Bug 1174386 - Make workers inherit the default Intl locale from the main thread, rather than using a bogus fallback value. r=jwalden, r=baku 2016-08-08 13:33:39 -07:00
test_localeService.js Backed out changeset 60d72c2dd49d (bug 1346616) for eslint failure in DirectoryLinksProvider.jsm. r=backout on a CLOSED TREE 2017-04-18 00:48:16 +02:00
test_localeService_negotiateLanguages.js 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
test_osPreferences.js Bug 1380916 - Introduce OSPreferences::GetRegionalPrefsLocales. r=jfkthame 2017-07-13 10:40:40 -07:00
test_pluralForm.js Bug 1340924 - Remove Iterator consumer from intl/. r=Pike 2017-02-22 16:11:34 +09:00
test_pluralForm_english.js
test_pluralForm_makeGetter.js
xpcshell.ini Bug 1313625 - Remove nsIScriptableDateFormat. r=jfkthame 2017-08-03 16:46:55 +09:00