Fix babel locale discovery for zh_Hans_US

This commit is contained in:
Raphael Michel
2026-01-23 11:35:37 +01:00
parent fd72e18a7f
commit 059179aecb
2 changed files with 2 additions and 1 deletions

View File

@@ -141,7 +141,7 @@ def get_babel_locale():
for locale in try_locales: for locale in try_locales:
if localedata.exists(locale): if localedata.exists(locale):
return locale return localedata.normalize_locale(locale)
return "en" return "en"

View File

@@ -59,6 +59,7 @@ def test_get_locale():
("pt-pt", "PT", "pt-pt", "pt-pt", "pt_PT"), ("pt-pt", "PT", "pt-pt", "pt-pt", "pt_PT"),
("es", "MX", "es-mx", "es", "es_MX"), ("es", "MX", "es-mx", "es", "es_MX"),
("es-419", "MX", "es-419", "es-419", "es_MX"), ("es-419", "MX", "es-419", "es-419", "es_MX"),
("zh-hans", "US", "zh-hans", "zh-hans", "zh_Hans"),
("zh-hans", "CN", "zh-hans", "zh-hans", "zh_Hans_CN"), ("zh-hans", "CN", "zh-hans", "zh-hans", "zh_Hans_CN"),
("zh-hant", "TW", "zh-hant", "zh-hant", "zh_Hant_TW"), ("zh-hant", "TW", "zh-hant", "zh-hant", "zh_Hant_TW"),
], ],