Add frontend Chinese English i18n
This commit is contained in:
@@ -36,7 +36,7 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
self.assertIsNotNone(index_file)
|
||||
index_html = index_file.read_text(encoding="utf-8")
|
||||
|
||||
for asset in ("/static/styles.css", "/static/app.js", "/static/trader_mode.js"):
|
||||
for asset in ("/static/styles.css", "/static/i18n.js", "/static/app.js", "/static/trader_mode.js"):
|
||||
with self.subTest(asset=asset):
|
||||
self.assertIn(asset, index_html)
|
||||
asset_file = _resolve_static_file(asset)
|
||||
@@ -48,7 +48,7 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
self.assertIsNotNone(training_file)
|
||||
training_html = training_file.read_text(encoding="utf-8")
|
||||
|
||||
for asset in ("/static/styles.css", "/static/training.js"):
|
||||
for asset in ("/static/styles.css", "/static/i18n.js", "/static/training.js"):
|
||||
with self.subTest(asset=asset):
|
||||
self.assertIn(asset, training_html)
|
||||
asset_file = _resolve_static_file(asset)
|
||||
@@ -60,7 +60,7 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
self.assertIsNotNone(trader_mode_file)
|
||||
trader_mode_html = trader_mode_file.read_text(encoding="utf-8")
|
||||
|
||||
for asset in ("/static/styles.css", "/static/app.js", "/static/trader_mode.js"):
|
||||
for asset in ("/static/styles.css", "/static/i18n.js", "/static/app.js", "/static/trader_mode.js"):
|
||||
with self.subTest(asset=asset):
|
||||
self.assertIn(asset, trader_mode_html)
|
||||
asset_file = _resolve_static_file(asset)
|
||||
@@ -85,6 +85,15 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
|
||||
|
||||
@unittest.skipIf(shutil.which("node") is None, "node is required for JS syntax checks")
|
||||
def test_i18n_javascript_syntax_is_valid(self) -> None:
|
||||
i18n_file = _resolve_static_file("/static/i18n.js")
|
||||
self.assertIsNotNone(i18n_file)
|
||||
|
||||
result = subprocess.run(["node", "--check", str(i18n_file)], capture_output=True, text=True, check=False)
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
|
||||
|
||||
@unittest.skipIf(shutil.which("node") is None, "node is required for JS syntax checks")
|
||||
def test_trader_mode_javascript_syntax_is_valid(self) -> None:
|
||||
trader_mode_file = _resolve_static_file("/static/trader_mode.js")
|
||||
@@ -131,6 +140,8 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
for expected in (
|
||||
'class="workbench-layout"',
|
||||
'id="workbenchNav"',
|
||||
'id="languageSelect"',
|
||||
'data-i18n-language-select',
|
||||
'data-workbench-target="trader-mode"',
|
||||
'data-workbench-section="trader-mode"',
|
||||
'id="traderStatusPanel"',
|
||||
@@ -156,9 +167,40 @@ class ApiStaticServerTests(unittest.TestCase):
|
||||
".workbench-sidebar",
|
||||
".workbench-nav button.is-active",
|
||||
".workspace-section.is-active",
|
||||
".language-switcher",
|
||||
):
|
||||
self.assertIn(expected, styles_css)
|
||||
|
||||
def test_frontend_exposes_default_chinese_i18n(self) -> None:
|
||||
index_file = _resolve_static_file("/")
|
||||
self.assertIsNotNone(index_file)
|
||||
index_html = index_file.read_text(encoding="utf-8")
|
||||
i18n_file = _resolve_static_file("/static/i18n.js")
|
||||
self.assertIsNotNone(i18n_file)
|
||||
i18n_js = i18n_file.read_text(encoding="utf-8")
|
||||
|
||||
for expected in (
|
||||
"DEFAULT_LOCALE = 'zh-CN'",
|
||||
"SUPPORTED_LOCALES",
|
||||
"AI ICT 交易工作台",
|
||||
"交易员模式",
|
||||
"决策助手",
|
||||
"仅观察",
|
||||
"不要使用",
|
||||
"只读实盘分析",
|
||||
"ai_ict_locale_v1",
|
||||
"ai-ict-locale-change",
|
||||
):
|
||||
self.assertIn(expected, i18n_js)
|
||||
|
||||
for expected in (
|
||||
"/static/i18n.js",
|
||||
'id="languageSelect"',
|
||||
'value="zh-CN"',
|
||||
'value="en"',
|
||||
):
|
||||
self.assertIn(expected, index_html)
|
||||
|
||||
def test_dashboard_uses_canonical_trading_routes(self) -> None:
|
||||
app_file = _resolve_static_file("/static/app.js")
|
||||
self.assertIsNotNone(app_file)
|
||||
|
||||
Reference in New Issue
Block a user