* feat: add vue-i18n * feat: add vue-i18n * feat: add vue-i18n * feat: add language class * add: en templates and configs * add: en names * refactor: name gender id and sect id * feat(i18n): add gettext infrastructure for dynamic text translation (#81) * feat(i18n): add gettext infrastructure for dynamic text translation - Add src/i18n/ module with t() translation function - Add .po/.mo files for zh_CN and en_US locales - Update LanguageManager to reload translations on language change - Add comprehensive tests (14 tests, all passing) - Add implementation spec at docs/specs/i18n-dynamic-text.md Phase 1 of i18n dynamic text implementation. * feat(i18n): expand .po files with comprehensive translation entries Add translation messages for: - Battle result messages (fatal/non-fatal outcomes) - Fortune event messages (item discovery, cultivation gains) - Misfortune event messages (losses, damage, regression) - Death reason messages - Item exchange messages (equip, sell, discard) - Single choice context and option labels - Common labels (weapon, auxiliary, technique, elixir) Both zh_CN and en_US locales updated with matching entries. * test: add .po file integrity tests * feat: i18n for actions * feat: i18n for effects * feat: i18n for gathering * feat: i18n for classes * feat: i18n for classes * feat: i18n for classes * feat: i18n for classes * fix bugs * fix bugs * fix bugs * fix bugs * fix bugs * fix bugs * fix bugs * fix bugs * update csv * update world info * update prompt * update prompt * fix bug * fix bug * fix bug * fix bug * fix bug * fix bug * fix bug * fix bug * fix bug * update * update * update * update * update * update * update --------- Co-authored-by: Zihao Xu <xzhseh@gmail.com>
42 lines
1.9 KiB
Python
42 lines
1.9 KiB
Python
import json
|
|
import os
|
|
import pytest
|
|
import sys
|
|
|
|
# Add src to path to import WeaponType
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
from src.classes.weapon_type import WeaponType
|
|
|
|
class TestFrontendLocales:
|
|
def test_popup_types_coverage(self):
|
|
"""Verify that ALL WeaponType keys are mapped in frontend locales"""
|
|
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
zh_path = os.path.join(base_dir, "web", "src", "locales", "zh-CN.json")
|
|
en_path = os.path.join(base_dir, "web", "src", "locales", "en-US.json")
|
|
|
|
assert os.path.exists(zh_path), "zh-CN.json not found"
|
|
assert os.path.exists(en_path), "en-US.json not found"
|
|
|
|
with open(zh_path, "r", encoding="utf-8") as f:
|
|
zh_data = json.load(f)
|
|
|
|
with open(en_path, "r", encoding="utf-8") as f:
|
|
en_data = json.load(f)
|
|
|
|
# Check for 'game.info_panel.popup.types'
|
|
zh_types = zh_data.get("game", {}).get("info_panel", {}).get("popup", {}).get("types", {})
|
|
en_types = en_data.get("game", {}).get("info_panel", {}).get("popup", {}).get("types", {})
|
|
|
|
# Verify all WeaponType enum values exist in locales
|
|
for member in WeaponType:
|
|
key = member.value
|
|
assert key in zh_types, f"Key '{key}' missing in zh-CN.json types"
|
|
assert key in en_types, f"Key '{key}' missing in en-US.json types"
|
|
|
|
# Ensure no Chinese keys exist (double check)
|
|
# The key itself should be the English enum value (e.g. "SPEAR"), not "枪"
|
|
assert not any(char > '\u4e00' and char < '\u9fff' for char in key), \
|
|
f"Key '{key}' contains Chinese characters, which is not allowed for localization keys."
|
|
|
|
print("All WeaponType keys verified successfully.")
|