** test: testGetBestMatchForList-exactMatch
@supported=fr, en-GB, ja, es-ES, es-MX
ja, de >> ja
@favor=script
ja, de >> ja
** test: testGetBestMatchForList-simpleVariantMatch
@supported=fr, en-GB, ja, es-ES, es-MX
de, en-US >> en-GB # Intentionally avoiding a perfect-match or two candidates for variant matches.
# Fallback.
de, zh >> fr
@favor=script
de, en-US >> en-GB
de, zh >> fr
** test: testGetBestMatchForList-matchOnMaximized
# Check that if the preference is maximized already, it works as well.
@supported=en, ja
ja-Jpan-JP, en-AU >> ja # Match for ja-Jpan-JP (maximized already)
# ja-JP matches ja on likely subtags, and it's listed first, thus it wins over the second preference en-GB.
ja-JP, en-US >> ja # Match for ja-Jpan-JP (maximized already)
# Check that if the preference is maximized already, it works as well.
ja-Jpan-JP, en-US >> ja # Match for ja-Jpan-JP (maximized already)
@favor=script
ja-Jpan-JP, en-AU >> ja
ja-JP, en-US >> ja
ja-Jpan-JP, en-US >> ja
** test: testGetBestMatchForList-noMatchOnMaximized
# Regression test for http://b/5714572 .
# de maximizes to de-DE. Pick the exact match for the secondary language instead.
@supported=en, de, fr, ja
de-CH, fr >> de
@favor=script
de-CH, fr >> de
** test: testBestMatchForTraditionalChinese
# Scenario: An application that only supports Simplified Chinese (and some other languages),
# but does not support Traditional Chinese. zh-Hans-CN could be replaced with zh-CN, zh, or
# zh-Hans, it wouldn't make much of a difference.
# The script distance (simplified vs. traditional Han) is considered small enough
# to be an acceptable match. The regional difference is considered almost insignificant.
@supported=fr, zh-Hans-CN, en-US
zh-TW >> fr # no match so get first
zh-Hant >> fr # no match so get first
# For geopolitical reasons, you might want to avoid a zh-Hant -> zh-Hans match.
# In this case, if zh-TW, zh-HK or a tag starting with zh-Hant is requested, you can
# change your call to getBestMatch to include a 2nd language preference.
# "en" is a better match since its distance to "en-US" is closer than the distance
# from "zh-TW" to "zh-CN" (script distance).
zh-TW, en >> en-US
zh-Hant-CN, en >> en-US
zh-Hans, en >> zh-Hans-CN
@favor=script
zh-TW >> fr # no match so get first
zh-Hant >> fr # no match so get first
zh-TW, en >> en-US
zh-Hant-CN, en >> en-US
zh-Hans, en >> zh-Hans-CN
** test: testUndefined
# When the undefined language doesn't match anything in the list,
# getBestMatch returns the default, as usual.
@supported=it, fr
und >> it
# When it *does* occur in the list, bestMatch returns it, as expected.
@supported=it, und
und >> und
# The unusual part: max("und") = "en-Latn-US", and since matching is based on maximized
# tags, the undefined language would normally match English. But that would produce the
# counterintuitive results that getBestMatch("und", XLocaleMatcher("it,en")) would be "en", and
# getBestMatch("en", XLocaleMatcher("it,und")) would be "und".
# To avoid that, we change the matcher's definitions of max
# so that max("und")="und". That produces the following, more desirable
# results:
@supported=it, en
und >> it
@supported=it, und
en >> it
@favor=script
@supported=it, fr
und >> it
@supported=it, und
und >> und
@supported=it, en
und >> it
@supported=it, und
en >> it
** test: testGetBestMatch-regionDistance
@supported=es-AR, es
es-MX >> es-AR
@supported=fr, en, en-GB
en-CA >> en
@supported=de-AT, de-DE, de-CH
de >> de-DE
@favor=script
@supported=es-AR, es
es-MX >> es-AR
@supported=fr, en, en-GB
en-CA >> en
@supported=de-AT, de-DE, de-CH
de >> de-DE
** test: testAsymmetry
@supported=mul, nl
af >> nl # af => nl
@supported=mul, af
nl >> mul # but nl !=> af
@favor=script
@supported=mul, nl
af >> nl
@supported=mul, af
nl >> mul
# Brazilian user who prefers South American Spanish over European Portuguese as a fallback.
# The asymmetry between this case and above is because it's "pt-PT" that's missing between the
# matchers as "pt-BR" is a much more common language.
** test: testBasicsWithDefault
@supported=en-GB, en
@default=fr
en-GB >> en-GB
en-US >> en
fr >> fr
ja >> fr
@favor=script
en-GB >> en-GB
en-US >> en
fr >> en
ja >> fr
** test: testEmptyWithDefault
@default=en
fr >> en
** test: testGetBestMatchForList_exactMatch
@supported=fr, en-GB, ja, es-ES, es-MX
ja, de >> ja
** test: testGetBestMatchForList_simpleVariantMatch
# Intentionally avoiding a perfect-match or two candidates for variant matches.
@supported=fr, en-GB, ja, es-ES, es-MX
de, en-US >> en-GB
# Fall back.
de, zh >> fr
** test: TestBasics
@supported=fr, en-GB, en
en-GB >> en-GB
en-US >> en
fr-FR >> fr
ja-JP >> fr
zu >> en
# For a language that doesn't match anything, return the default.
zxx >> fr
@favor=script
en-GB >> en-GB
en-US >> en
fr-FR >> fr
ja-JP >> fr
zu >> en
zxx >> en
** test: TestExactMatch
@supported=fr, en-GB, ja, es-ES, es-MX
ja, de >> ja
** test: TestSimpleVariantMatch
@supported=fr, en-GB, ja, es-ES, es-MX
de, en-US >> en-GB
de, zh >> fr
** test: TestMatchOnMaximized
# ja-JP matches ja on likely subtags, and it's listed first, thus it wins
# over the secondary preference en-GB.
@supported=fr, en-GB, ja, es-ES, es-MX
ja-JP, en-GB >> ja
# Check that if the preference is maximized already, it works as well.
ja-Jpan-JP, en-GB >> ja
@supported=fr, zh-Hant, en
zh, en >> en
@favor=script
zh, en >> en
** test: TestCloseEnoughMatchOnMaximized
@supported=en-GB, en, de, fr, ja
de-CH, fr >> de
en-US, ar, nl, de, ja >> en
** test: TestGetBestMatchForPortuguese
# 1. a supported set containing an explicit pt: {pt-PT, pt-BR, es, es-419}
# 2. a supported set containing an implicit pt: {pt-PT, pt, es, es-419}
# 3. a supported set containing no pt: {pt-BR, es, es-419}
# European user who prefers Spanish over Brazilian Portuguese as a fallback.
@supported=pt-PT, pt-BR, es, es-419
pt-PT, es, pt >> pt-PT
@supported=pt-PT, pt, es, es-419
pt-PT, es, pt >> pt-PT
@supported=pt-BR, es, es-419
pt-PT, es, pt >> pt-BR
# Brazilian user who prefers South American Spanish over European Portuguese
# as a fallback. The asymmetry between this case and above is because it's
# "pt-PT" that's missing between the matchers.
@supported=pt-PT, pt-BR, es, es-419
pt, es-419, pt-PT >> pt-BR
@supported=pt-PT, pt, es, es-419
pt, es-419, pt-PT >> pt
@supported=pt-BR, es, es-419
pt, es-419, pt-PT >> pt-BR
# Sometimes we get "pt-US" for a user's language (which CLDR doesn't
# recognize) but we deal with that as a synonym for "pt-BR".
@supported=pt-PT, pt-BR, es, es-419
pt-US, pt-PT >> pt-BR
@supported=pt-PT, pt, es, es-419
pt-US, pt-PT >> pt
** test: TestScriptAndRegion
@supported=en-GB, en
en-CA >> en
# fr-CA is a "close enough" match to "fr" to be returned in favor of "en-GB"
@supported=fr, en-GB, en
fr-CA, en-CA >> fr
@supported=zh-Hant, zh-TW
zh-HK >> zh-Hant
@favor=script
@supported=en-GB, en
en-CA >> en
@supported=fr, en-GB, en
fr-CA, en-CA >> fr
@supported=zh-Hant, zh-TW
zh-HK >> zh-Hant
** test: TestFallbackWithDefault
# Check that script fallbacks are handled right and that we don't have to
# fall back to the default.
@supported=zh-CN, zh-TW, iw
@default=fr
zh-Hant >> zh-TW
zh >> zh-CN
zh-Hans-CN >> zh-CN
zh-Hant-HK >> zh-TW
he-IT >> iw
** test: TestSpecials
# Check that nearby languages are handled.
@supported=en, fil, ro, nn
tl >> fil
mo >> ro
nb >> nn
ja >> en # Make sure default works.
** test: TestRegionalSpecials
# Verify that en-AU is closer to en-GB than to en (which is en-US).
@supported=en, en-GB, es-ES, es-419
en-AU >> en-GB
# Following 2 cases test closer/smaller region difference.
es-MX >> es-419
es-PT >> es-ES
** test: TestUndefined
# When the undefined language doesn't match anything in the list,
# return the default.
@supported=it, fr
und >> it
# When it *does* occur in the list, return it.
@supported=it, und
und >> und
# The unusual part:
# max("und") = "en-Latn-US", and since matching is based on
# maximized tags, the undefined language would normally match
# English. But that would produce the counterintuitive results
# that BestMatchFor("und", LanguageMatcher("it,en")) would be "en",
# and BestMatchFor("en", LanguageMatcher("it,und")) would be "und".
# To avoid that, we change the matcher's definitions of max
# (AddLikelySubtagsWithDefaults) so that max("und")="und". That
# produces the following, more desirable results:
@supported=it, en
und >> it
@supported=it, und
en >> it
** test: TestVariantWithScriptMatch
@supported=fr, en, sv
en-GB >> en
en-GB, sv >> en
@favor=script
en-GB, sv >> en
** test: Serbian
@supported=und, sr
sr-ME >> sr
@supported=und, sr-ME
sr >> sr-ME
@supported=und, sr-Latn
bs >> und
@supported=und, bs
sr-Latn >> und
@supported=und, sr
bs >> und
@supported=und, bs
sr >> und
@supported=und, sr-Latn
sr >> sr-Latn
@supported=und, sr
sr-Latn >> sr
@favor=script
sr-ME >> sr
@supported=und, sr-ME
sr >> sr-ME
@supported=und, sr-Latn
bs >> sr-Latn
@supported=und, bs
sr-Latn >> bs
@supported=und, sr
bs >> und
@supported=und, bs
sr >> und
@supported=und, sr-Latn
sr >> sr-Latn
@supported=und, sr
sr-Latn >> sr
** test: DoNotMatchGooglePseudoLocale
@supported=fr, en-XA, ar-XB, en-PSACCENT, ar-PSBIDI, en-DE, pt, ar-SY, ar-PSCRACK
de >> fr
# We wouldn't want to return pseudo locales when there's a good match for an
# ordinary locale.
# Note: If LanguageMatcher was not aware of PSACCENT, it would consider the
# distance from "en" to "en-PSACCENT" smaller than to "en-DE" (the standard
# variant distance is smaller than a region distance).
en >> en-DE
ar-EG >> ar-SY
pt-BR >> pt
ar-XB >> ar-XB
ar-PSBIDI >> ar-PSBIDI
en-XA >> en-XA
en-PSACCENT >> en-PSACCENT
ar-PSCRACK >> ar-PSCRACK
** test: BestMatchForTraditionalChinese
# Scenario: An application that only supports Simplified Chinese (and some
# other languages), but does not support Traditional Chinese. zh-Hans-CN
# could be replaced with zh-CN, zh, or zh-Hans, it wouldn't make much of a
# difference.
# The script distance (simplified vs. traditional Han) is considered small
# enough to be an acceptable match. The regional difference is considered
# almost insignificant.
@supported=fr, zh-Hans-CN, en-US
zh-TW >> fr # no match so get first
zh-Hant >> fr # no match so get first
# For geopolitical reasons, you might want to avoid a zh-Hant -> zh-Hans
# match. In this case, if zh-TW, zh-HK or a tag starting with zh-Hant is
# requested, you can change your call to getBestMatch to include a 2nd
# language preference. "en" is a better match since its distance to "en-US"
# is closer than the distance from "zh-TW" to "zh-CN" (script distance).
zh-TW, en >> en-US
zh-Hant-CN, en >> en-US
zh-Hans, en >> zh-Hans-CN
** test: MaxBeforeEquals
# Compare maximized forms of earlier items before testing equality
# of later items.
@supported=en, fr-CA
en-US, fr-CA >> en
@favor=script
en-US, fr-CA >> en
** test: SiblingDefaultRegion
@supported=de-AT, de-DE, de-CH
de >> de-DE
** test: ReturnDefaultInsteadOfNullForEmptyPriorityList
@default=und
de >> und
** test: ReturnSpecifiedDefaultForNoMatch
@supported=de, en, fr
@default=und
hi >> und
# United States fallback
en-CA >> en-US
en-US >> en-US
en >> en-US
@favor=script
und >> und
ja >> und
fr-CA >> en-US
en-AU >> en-GB
en-BZ >> en-GB
en-CA >> en-US
en-IN >> en-GB
en-IE >> en-GB
en-JM >> en-GB
en-NZ >> en-GB
en-PK >> en-GB
en-TT >> en-GB
en-ZA >> en-GB
en-US >> en-US
en >> en-US
** test: TestFallback
# manyEnMatcher
@supported=en-GB, en-US, en, en-AU
@default=und
und >> und
ja >> und
fr-CA >> und
# nonUsMatcher
fr >> und
# onlyAuMatcher
@supported=en-AU, ja, ca
fr >> und
# noEnMatcher
@supported=pl, ja, ca
fr >> und
@favor=script
@supported=en-GB, en-US, en, en-AU
und >> und
ja >> und
fr-CA >> en-US
fr >> en-US
@supported=en-AU, ja, ca
fr >> en-AU
@supported=pl, ja, ca
fr >> pl
## Go
** test: basics
@supported=fr, en-GB, en
en-GB >> en-GB
en-US >> en
fr-FR >> fr
ja-JP >> fr
** test: language-specific script fallbacks 1
@supported=en, sr, nl
sr-Latn >> sr
sh >> en
hr >> en
bs >> en
nl-Cyrl >> en # Mark: Expected value should be en not sr. Script difference exceeds threshold, so can't be nl
@favor=script
sr-Latn >> sr
hr >> en
bs >> en
nl-Cyrl >> sr
** test: language-specific script fallbacks 2
@supported=en, sr-Latn
sr >> sr-Latn
sr-Cyrl >> sr-Latn
@default=und
hr >> und
@favor=script
@default=
sr >> sr-Latn
sr-Cyrl >> sr-Latn
@default=und
hr >> en
** test: don't match hr to sr-Latn
@supported=en, sr-Latn
hr >> en
@favor=script
hr >> en
** test: both deprecated and not
@supported=fil, tl, iw, he
he-IT >> iw
he >> iw
iw >> iw
fil-IT >> fil
fil >> fil
tl >> fil
** test: simple variant match
@supported=fr, en-GB, ja, es-ES, es-MX
de, en-US >> en-GB
de, zh >> fr
** test: best match for traditional Chinese
@supported=fr, zh-Hans-CN, en-US
zh-TW >> fr # no match so get first
zh-Hant >> fr # no match so get first
zh-TW, en >> en-US
zh-Hant-CN, en >> en-US
zh-Hans, en >> zh-Hans-CN
** test: return most originally similar among likely-subtags equivalent locales
@supported=af, af-Latn, af-Arab
af >> af
af-ZA >> af
af-Latn-ZA >> af-Latn
af-Latn >> af-Latn
@favor=script
af >> af
af-ZA >> af
af-Latn-ZA >> af-Latn
af-Latn >> af-Latn
** test: region may replace matched if matched is enclosing
@supported=es-419, es
@default=es-MX
es-MX >> es-419
@default=
es-SG >> es
@favor=script
@default=es-MX
es-MX >> es-419
@default=
es-SG >> es
** test: region distance Portuguese
@supported=pt, pt-PT
pt-ES >> pt-PT
@favor=script
pt-ES >> pt-PT
** test: if no preferred locale specified, pick top language, not regional
@supported=en, fr, fr-CA, fr-CH
fr-US >> fr
@favor=script
fr-US >> fr
** test: region distance German
@supported=de-AT, de-DE, de-CH
de >> de-DE
** test: en-AU is closer to en-GB than to en (which is en-US)
@supported=en, en-GB, es-ES, es-419
en-AU >> en-GB
@default=es-MX
es-MX >> es-419
@default=
es-PT >> es-ES
** test: same language over exact, but distinguish when user is explicit
@supported=fr, en-GB, ja, es-ES, es-MX
ja, de >> ja
@supported=en, de, fr, ja
de-CH, fr >> de
@supported=en-GB, nl
en, nl >> en-GB
en, nl, en-GB >> en-GB
@favor=script
@supported=fr, en-GB, ja, es-ES, es-MX
ja, de >> ja
@supported=en, de, fr, ja
de-CH, fr >> de
@supported=en-GB, nl
en, nl >> en-GB
en, nl, en-GB >> en-GB
** test: testGetBestMatchWithMinMatchScore
@supported=fr-FR, fr, fr-CA, en
@default=und
fr >> fr
@supported=en, fr, fr-CA
fr-FR >> fr # Parent match is chosen.
@supported=en, fr-CA
fr-FR >> fr-CA # Sibling match is chosen.
@supported=fr-CA, fr-FR
fr >> fr-FR # Inferred region match is chosen.
fr-SN >> fr-FR
@supported=en, fr-FR
fr >> fr-FR # Child match is chosen.
@supported=de, en, it
fr >> und
@supported=iw, en
iw-Latn >> und
@supported=iw, no
ru >> und
@supported=iw-Latn, iw-Cyrl, iw
ru >> und
@supported=iw, iw-Latn
ru >> und
en >> und
@supported=en, uk
ru >> und
@supported=zh-TW, en
zh-CN >> und # no match
@supported=ja
ru >> und
@favor=script
@supported=fr-FR, fr, fr-CA, en
fr >> fr
@supported=en, fr, fr-CA
fr-FR >> fr
@supported=en, fr-CA
fr-FR >> fr-CA
@supported=fr-CA, fr-FR
fr >> fr-FR
fr-SN >> fr-FR
@supported=en, fr-FR
fr >> fr-FR
@supported=de, en, it
fr >> en
@supported=iw, en
iw-Latn >> en
@supported=iw, no
ru >> und
@supported=iw-Latn, iw-Cyrl, iw
ru >> iw-Cyrl
@supported=iw, iw-Latn
ru >> und
en >> iw-Latn
@supported=en, uk
ru >> uk
@supported=zh-TW, en
zh-CN >> und # no match
@supported=ja
ru >> und
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.