fix(naming): correct language tag rule matching and add state conditions

Rules took only a scalar, so the documented list syntax raised LanguageTagError after the mux. Normalise every condition, treat an invalid tag as no match, guard the surrounding post-mux config reads, and let a rule match dual, multi and dubbed so a release can carry its own tag.
This commit is contained in:
imSp4rky
2026-09-11 20:00:08 -06:00
parent f43b90d6b6
commit c8a674d85d
9 changed files with 207 additions and 18 deletions
+12
View File
@@ -153,6 +153,18 @@ def is_close_match(language: Union[str, Language], languages: Sequence[Union[str
return closest_match(language, list(map(str, languages)))[1] <= LANGUAGE_MAX_DISTANCE
def valid_language(language: Any) -> Optional[str]:
"""Return the language tag as text, or None when it is not a valid tag."""
if not language:
return None
try:
Language.get(str(language))
except LanguageTagError:
logging.getLogger("utilities").warning("%r is not a valid language tag, ignoring it", language)
return None
return str(language)
def is_exact_match(language: Union[str, Language], languages: Sequence[Union[str, Language, None]]) -> bool:
"""Examine whether a language exactly matches any of the given languages."""
languages = [x for x in languages if x]