Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language codes for Hebrew #93681

Merged
merged 9 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions homeassistant/util/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def is_language_match(lang_1: str, lang_2: str) -> bool:
# nb = written Norwegian (Bokmål)
return True

if {lang_1, lang_2} == {"iw", "he"}:
# he = Hebrew new code
# iw = Hebrew old code
return True

return False


Expand Down
36 changes: 36 additions & 0 deletions tests/util/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,39 @@
"no-AA",
["en-US", "en-GB", "no-AA", "nb-AA"],
) == ["no-AA", "nb-AA"]


def test_he_iw_same() -> None:
"""Test that the he/iw are interchangeable."""
assert language.matches(
"he",
["en-US", "en-GB", "iw"],
) == ["iw"]
assert language.matches(
"iw",
["en-US", "en-GB", "he"],
) == ["he"]


def test_he_iw_prefer_exact() -> None:
"""Test that the exact language is preferred even if an interchangeable language is available."""
assert language.matches(

Check failure on line 245 in tests/util/test_language.py

View workflow job for this annotation

GitHub Actions / Run tests Python 3.10 (10)

test_he_iw_prefer_exact AssertionError: assert ['he'] == ['he', 'iw'] Right contains one more item: 'iw' Full diff: - ['he', 'iw'] + ['he']

Check failure on line 245 in tests/util/test_language.py

View workflow job for this annotation

GitHub Actions / Run tests Python 3.11 (10)

test_he_iw_prefer_exact AssertionError: assert ['he'] == ['he', 'iw'] Right contains one more item: 'iw' Full diff: - ['he', 'iw'] + ['he']
"he",
["en-US", "en-GB", "nb", "he"],
) == ["he", "iw"]
assert language.matches(
"he",
["en-US", "en-GB", "he", "iw"],
) == ["he", "iw"]


def test_he_iw_prefer_exact_regions() -> None:
"""Test that the exact language/region is preferred."""
assert language.matches(
"he-IL",
["en-US", "en-GB", "iw-IL", "he-IL"],
) == ["he-IL", "iw-IL"]
assert language.matches(
"he-IL",
["en-US", "en-GB", "he-IL", "iw-IL"],
) == ["he-IL", "iw-IL"]