Merge pull request #758 from mvalentsev/fix/i18n-review-issues

fix: address i18n review issues from PR #718
This commit is contained in:
Igor Lins e Silva
2026-04-15 13:45:49 -03:00
committed by GitHub
3 changed files with 19 additions and 17 deletions
+1 -1
View File
@@ -362,7 +362,7 @@ class Dialect:
return cls(
entities=config.get("entities", {}),
skip_names=config.get("skip_names", []),
lang=config.get("lang"),
lang=config.get("lang", "en"),
)
def save_config(self, config_path: str):
+1 -1
View File
@@ -25,7 +25,7 @@
"status_palace": "궁전: {path}",
"status_wings": "날개 {count}개",
"status_closets": "벽장 {count}개",
"status_drawers": "서랍 {drawers}개",
"status_drawers": "서랍 {count}개",
"init_complete": "{path}에 궁전 초기화 완료",
"init_exists": "{path}에 궁전이 이미 존재합니다",
"repair_complete": "수리 완료. {fixed}개 문제 해결.",
@@ -1,11 +1,4 @@
#!/usr/bin/env python3
"""Quick smoke test for i18n dictionaries + Dialect integration."""
import sys
from pathlib import Path
# Add parent to path so we can import mempalace
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
"""Smoke tests for i18n dictionaries + Dialect integration."""
from mempalace.i18n import load_lang, t, available_languages
from mempalace.dialect import Dialect
@@ -75,10 +68,19 @@ def test_dialect_compress_samples():
print(" PASS: compression works for all sample languages")
if __name__ == "__main__":
print("i18n smoke tests:")
test_all_languages_load()
test_interpolation()
test_dialect_loads_lang()
test_dialect_compress_samples()
print("\nAll tests passed.")
def test_korean_status_drawers_uses_count():
"""ko.json status_drawers must use {count}, not {drawers}."""
load_lang("ko")
result = t("cli.status_drawers", count=42)
assert "42" in result, f"Expected '42' in '{result}' -- count variable not interpolated"
def test_from_config_defaults_to_english(tmp_path):
"""Dialect.from_config without a lang key must not inherit module-level state."""
load_lang("ko") # pollute module-level _current_lang
config_path = tmp_path / "config.json"
config_path.write_text('{"entities": {}}')
d = Dialect.from_config(str(config_path))
assert d.lang == "en", f"Expected 'en', got '{d.lang}' -- state leak from prior load_lang"