Skip to content

Commit 76e964d

Browse files
authored
Merge pull request #606 from lbedner/traditional-chinese
Traditional Chinese
2 parents 9db0db8 + 31ebc84 commit 76e964d

15 files changed

Lines changed: 3100 additions & 18 deletions

File tree

aegis/__main__.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,26 @@ def main(
6565
lang: str | None = typer.Option(
6666
None,
6767
"--lang",
68-
help="Output language (en, ja, ko, zh). Default: auto-detect from AEGIS_LANG or system locale",
68+
help="Output language (en, ja, ko, zh, zh_Hant). Default: auto-detect from AEGIS_LANG or system locale",
6969
envvar="AEGIS_LANG",
7070
),
7171
) -> None:
7272
"""Aegis Stack CLI - Global options and configuration."""
7373
set_verbose(verbose)
74-
if lang and lang.lower() not in AVAILABLE_LOCALES:
75-
typer.secho(
76-
f"Unsupported language '{lang}'. Available: {', '.join(sorted(AVAILABLE_LOCALES))}",
77-
fg="red",
78-
err=True,
79-
)
80-
raise typer.Exit(1)
74+
if lang:
75+
from .i18n.registry import _normalize_locale
76+
77+
resolved = _normalize_locale(lang)
78+
# _normalize_locale falls back to "en" for unknown inputs,
79+
# so check if the input actually maps to a real locale
80+
base = lang.lower().replace("-", "_").split(".")[0].split("@")[0]
81+
if resolved == "en" and not base.startswith("en"):
82+
typer.secho(
83+
f"Unsupported language '{lang}'. Available: {', '.join(sorted(AVAILABLE_LOCALES))}",
84+
fg="red",
85+
err=True,
86+
)
87+
raise typer.Exit(1)
8188
set_locale(lang if lang else detect_locale())
8289

8390

aegis/i18n/locales/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Available locales for Aegis Stack CLI."""
22

3-
AVAILABLE_LOCALES: set[str] = {"en", "ja", "ko", "zh"}
3+
AVAILABLE_LOCALES: set[str] = {"en", "ja", "ko", "zh", "zh_Hant"}

aegis/i18n/locales/zh_hant.py

Lines changed: 597 additions & 0 deletions
Large diffs are not rendered by default.

aegis/i18n/registry.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ def detect_locale() -> str:
4444
def _normalize_locale(raw: str) -> str:
4545
"""Normalize locale string to a supported code.
4646
47-
Maps zh_CN, zh-Hans, zh_TW, zh -> 'zh'
47+
Maps zh_CN, zh-Hans, zh -> 'zh' (Simplified)
48+
Maps zh_TW, zh_HK, zh-Hant -> 'zh_Hant' (Traditional)
4849
Maps en_US, en-GB, en -> 'en'
4950
Unsupported locales fall back to 'en'
5051
"""
51-
code = raw.lower().replace("-", "_").split("_")[0]
52+
normalized = raw.lower().replace("-", "_").split(".")[0].split("@")[0]
5253
from .locales import AVAILABLE_LOCALES
5354

55+
# Traditional Chinese variants
56+
if normalized in ("zh_tw", "zh_hk", "zh_hant", "zh_mo"):
57+
return "zh_Hant"
58+
59+
code = normalized.split("_")[0]
5460
if code in AVAILABLE_LOCALES:
5561
return code
5662
return "en"
@@ -73,6 +79,10 @@ def _load_locale(locale: str) -> None:
7379
from .locales.ko import MESSAGES
7480

7581
_messages["ko"] = MESSAGES
82+
elif locale == "zh_Hant":
83+
from .locales.zh_hant import MESSAGES
84+
85+
_messages["zh_Hant"] = MESSAGES
7686

7787
# Always ensure English is available as fallback
7888
if "en" not in _messages:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Available locales for the project CLI."""
22

3-
AVAILABLE_LOCALES: set[str] = {"en", "ja", "ko", "zh"}
3+
AVAILABLE_LOCALES: set[str] = {"en", "ja", "ko", "zh", "zh_Hant"}

aegis/templates/copier-aegis-project/{{ project_slug }}/app/i18n/locales/en.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"main.unsupported_lang": "Unsupported language '{lang}'. Available: {available}",
1414
# Help text
1515
"main.help": "Project management CLI",
16-
"main.opt_lang": "Output language (en, ja, ko, zh). Default: auto-detect",
16+
"main.opt_lang": "Output language (en, ja, ko, zh, zh_Hant). Default: auto-detect",
1717
# ── Health ────────────────────────────────────────────────────────
1818
"health.count_healthy": "{count} healthy",
1919
"health.count_warning": "{count} warning",

aegis/templates/copier-aegis-project/{{ project_slug }}/app/i18n/locales/ja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"main.unsupported_lang": "未対応の言語 '{lang}'。利用可能:{available}",
1414
# ヘルプ
1515
"main.help": "プロジェクト管理CLI",
16-
"main.opt_lang": "出力言語(en、ja、ko、zh)。デフォルト:自動検出",
16+
"main.opt_lang": "出力言語(en、ja、ko、zh、zh_Hant)。デフォルト:自動検出",
1717
# ── ヘルスチェック ─────────────────────────────────────────────────
1818
"health.count_healthy": "{count} 件正常",
1919
"health.count_warning": "{count} 件警告",

aegis/templates/copier-aegis-project/{{ project_slug }}/app/i18n/locales/ko.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"main.unsupported_lang": "지원하지 않는 언어입니다: '{lang}'. 사용 가능: {available}",
1414
# Help text
1515
"main.help": "프로젝트 관리 CLI",
16-
"main.opt_lang": "출력 언어 (en, ja, ko, zh). 기본값: 자동 감지",
16+
"main.opt_lang": "출력 언어 (en, ja, ko, zh, zh_Hant). 기본값: 자동 감지",
1717
# ── Health ────────────────────────────────────────────────────────
1818
"health.count_healthy": "{count}개 정상",
1919
"health.count_warning": "{count}개 경고",

aegis/templates/copier-aegis-project/{{ project_slug }}/app/i18n/locales/zh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"main.unsupported_lang": "不支持的语言 '{lang}'。可用语言:{available}",
1414
# 帮助文本
1515
"main.help": "项目命令行工具",
16-
"main.opt_lang": "输出语言(en、ja、ko、zh),默认自动检测系统语言",
16+
"main.opt_lang": "输出语言(en、ja、ko、zh、zh_Hant),默认自动检测系统语言",
1717
# ── 健康检查 ──────────────────────────────────────────────────────
1818
"health.count_healthy": "{count} 个正常",
1919
"health.count_warning": "{count} 个警告",

0 commit comments

Comments
 (0)