Allow "no" to match "nb" in language util (#92862)
* Allow "no" to match "nb" * Adjust comparison for speed
This commit is contained in:
parent
7d29d584fd
commit
5d6ccd6a32
2 changed files with 69 additions and 10 deletions
|
@ -190,3 +190,39 @@ def test_sr_latn() -> None:
|
|||
"sr-CS",
|
||||
"sr-RS",
|
||||
]
|
||||
|
||||
|
||||
def test_no_nb_same() -> None:
|
||||
"""Test that the no/nb are interchangeable."""
|
||||
assert language.matches(
|
||||
"no",
|
||||
["en-US", "en-GB", "nb"],
|
||||
) == ["nb"]
|
||||
assert language.matches(
|
||||
"nb",
|
||||
["en-US", "en-GB", "no"],
|
||||
) == ["no"]
|
||||
|
||||
|
||||
def test_no_nb_prefer_exact() -> None:
|
||||
"""Test that the exact language is preferred even if an interchangeable language is available."""
|
||||
assert language.matches(
|
||||
"no",
|
||||
["en-US", "en-GB", "nb", "no"],
|
||||
) == ["no", "nb"]
|
||||
assert language.matches(
|
||||
"no",
|
||||
["en-US", "en-GB", "no", "nb"],
|
||||
) == ["no", "nb"]
|
||||
|
||||
|
||||
def test_no_nb_prefer_exact_regions() -> None:
|
||||
"""Test that the exact language/region is preferred."""
|
||||
assert language.matches(
|
||||
"no-AA",
|
||||
["en-US", "en-GB", "nb-AA", "no-AA"],
|
||||
) == ["no-AA", "nb-AA"]
|
||||
assert language.matches(
|
||||
"no-AA",
|
||||
["en-US", "en-GB", "no-AA", "nb-AA"],
|
||||
) == ["no-AA", "nb-AA"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue