From 8c47e8b92f0a18e36ee63f7e54c8efe48a2fbbff Mon Sep 17 00:00:00 2001 From: Palash Debnath <4178343+debpalash@users.noreply.github.com> Date: Thu, 17 Sep 2026 12:16:09 +0530 Subject: [PATCH] fix: consolidate Argos coverage and reject silent script changes --- CHANGELOG.md | 4 ++++ backend/services/translation_engines.py | 7 ++++++- docs/dubbing/translation-engines.md | 2 ++ tests/test_dub_translate.py | 8 +++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c6df8b7..d49b8744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ the frozen-backend fallback mirror it for their toolchains. - Handle missing Electron signing credentials and retry packaging fixes without moving release tags (#2157) +### Fixed + +- Normalize Argos language aliases without silently changing Traditional Chinese to Simplified (#2143, #2152) — thanks @gyanu2507 and @rollroyces! + ## [0.5.3] — 2026-09-17 **Highlights** diff --git a/backend/services/translation_engines.py b/backend/services/translation_engines.py index 64704ae5..5b2b957d 100644 --- a/backend/services/translation_engines.py +++ b/backend/services/translation_engines.py @@ -40,7 +40,6 @@ _ARGOS_LANG_ALIASES = { _ARGOS_NAME_ALIASES = { "chinese": "zh", "chinese (simplified)": "zh", - "chinese (traditional)": "zh", "mandarin": "zh", } @@ -325,6 +324,12 @@ def argos_lang_code(value: str) -> str: """ raw = str(value or "").strip() key = raw.lower() + parts = key.replace("_", "-").split("-") + if key == "chinese (traditional)" or ( + parts[0] in {"zh", "zho", "cmn"} and + any(part in {"hant", "tw", "hk", "mo"} for part in parts[1:]) + ): + raise ValueError("Argos does not provide Traditional Chinese; choose NLLB for this script") named = _ARGOS_NAME_ALIASES.get(key) if named: return named diff --git a/docs/dubbing/translation-engines.md b/docs/dubbing/translation-engines.md index f1654ca5..3dba9a4d 100644 --- a/docs/dubbing/translation-engines.md +++ b/docs/dubbing/translation-engines.md @@ -234,3 +234,5 @@ panels instead so neither editor becomes unusably small. from-source checkout. - **Installed it but still "needs install"** — restart the backend so Python picks up the newly-installed module. + +Argos accepts Chinese/Simplified Chinese names, Mandarin aliases, and language tags such as `zh-CN`. Traditional Chinese requests (`zh-TW`, `zh-Hant`, and the display name) are rejected explicitly; select NLLB for Traditional Chinese rather than silently receiving a different script. diff --git a/tests/test_dub_translate.py b/tests/test_dub_translate.py index ec5fdb32..6133eb8a 100644 --- a/tests/test_dub_translate.py +++ b/tests/test_dub_translate.py @@ -22,7 +22,6 @@ def test_translate_codes_cover_popular_iso(): # Human / display names from the dub UI's own label list. ("Chinese", "zh"), ("Chinese (Simplified)", "zh"), - ("Chinese (Traditional)", "zh"), ("Mandarin", "zh"), # Three-letter ISO 639-2 / bibliographic codes used by some asset pipelines. ("zho", "zh"), @@ -826,3 +825,10 @@ async def test_openai_env_fallback_still_works(monkeypatch): resp = await dub_translate.dub_translate(req) assert resp["translated"][0]["text"] == "hola mundo" assert calls and calls[0]["model"] == "env-model" + + +@pytest.mark.parametrize("raw", ["Chinese (Traditional)", "zh-TW", "zh-Hant", "cmn-Hant", "zho_Hant", "zh-HK", "zh-MO"]) +def test_argos_does_not_silently_change_chinese_script(raw): + from services.translation_engines import argos_lang_code + with pytest.raises(ValueError, match="Traditional Chinese.*NLLB"): + argos_lang_code(raw)