Skip to content

Commit dbefff1

Browse files
committed
Preserve platform plugin notification translations
1 parent c6c9ac5 commit dbefff1

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/quant_platform_kit/common/notification_localization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
def merge_strategy_plugin_i18n(
300300
i18n: dict[str, dict[str, str]],
301301
*,
302-
shared_wins: bool = True,
302+
shared_wins: bool = False,
303303
) -> dict[str, dict[str, str]]:
304304
merged = {str(locale): dict(values) for locale, values in i18n.items()}
305305
for locale, shared_values in STRATEGY_PLUGIN_I18N.items():

tests/test_notification_localization.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_strategy_plugin_i18n_has_matching_locale_keys(self):
8080
self.assertIn("strategy_plugin_name_taco_rebound_shadow", STRATEGY_PLUGIN_I18N["zh"])
8181
self.assertEqual(STRATEGY_PLUGIN_I18N["zh"]["strategy_plugin_name_taco_rebound_shadow"], "TACO 反弹观察通知")
8282

83-
def test_merge_strategy_plugin_i18n_fills_and_overrides_shared_keys(self):
83+
def test_merge_strategy_plugin_i18n_fills_missing_keys_without_overriding_callers(self):
8484
merged = merge_strategy_plugin_i18n(
8585
{
8686
"zh": {
@@ -92,6 +92,20 @@ def test_merge_strategy_plugin_i18n_fills_and_overrides_shared_keys(self):
9292
)
9393

9494
self.assertEqual(merged["zh"]["no_trades"], "无需调仓")
95+
self.assertEqual(merged["zh"]["strategy_plugin_name_taco_rebound_shadow"], "TACO 旧观察通知")
96+
self.assertEqual(merged["en"]["strategy_plugin_name_taco_rebound_shadow"], "TACO Rebound Watch Notice")
97+
98+
def test_merge_strategy_plugin_i18n_can_prefer_shared_keys(self):
99+
merged = merge_strategy_plugin_i18n(
100+
{
101+
"zh": {
102+
"strategy_plugin_name_taco_rebound_shadow": "TACO 旧观察通知",
103+
},
104+
"en": {},
105+
},
106+
shared_wins=True,
107+
)
108+
95109
self.assertEqual(merged["zh"]["strategy_plugin_name_taco_rebound_shadow"], "TACO 反弹观察通知")
96110
self.assertEqual(merged["en"]["strategy_plugin_route_watch"], "watch")
97111

0 commit comments

Comments
 (0)