2929 "market_data" : ("市场数据" , "market data" ),
3030}
3131
32+ _LONG_BRIDGE_ZH_NOTIFICATION_REPLACEMENTS = (
33+ ("regime=hard_defense" , "市场阶段=强防御" ),
34+ ("regime=soft_defense" , "市场阶段=软防御" ),
35+ ("regime=risk_on" , "市场阶段=进攻" ),
36+ ("benchmark_trend=down" , "基准趋势=向下" ),
37+ ("benchmark_trend=up" , "基准趋势=向上" ),
38+ ("benchmark=down" , "基准趋势=向下" ),
39+ ("benchmark=up" , "基准趋势=向上" ),
40+ ("breadth=" , "市场宽度=" ),
41+ ("target_stock=" , "目标股票仓位=" ),
42+ ("realized_stock=" , "实际股票仓位=" ),
43+ ("stock_exposure=" , "股票目标仓位=" ),
44+ ("safe_haven=" , "避险仓位=" ),
45+ ("selected=" , "入选标的数=" ),
46+ ("top=" , "前排标的=" ),
47+ ("partial_history_refresh" , "部分行情刷新" ),
48+ ("full_history_refresh" , "完整行情刷新" ),
49+ ("universe_fallback" , "股票池复用" ),
50+ )
51+
52+ _SOURCE_INPUT_STATUS_LABELS = {
53+ "partial_history_refresh" : ("部分行情刷新" , "partial history refresh" ),
54+ "full_history_refresh" : ("完整行情刷新" , "full history refresh" ),
55+ "universe_fallback" : ("股票池复用" , "universe fallback" ),
56+ }
57+
3258try :
3359 from quant_platform_kit .common .notification_localization import (
3460 localize_price_source_label as _shared_localize_price_source_label ,
@@ -57,7 +83,31 @@ def _translator_uses_zh(translator) -> bool:
5783
5884
5985def _localize_notification_text (text , * , translator ):
60- return _base_localize_notification_text (text , translator = translator )
86+ try :
87+ return _base_localize_notification_text (
88+ text ,
89+ translator = translator ,
90+ extra_replacements = _LONG_BRIDGE_ZH_NOTIFICATION_REPLACEMENTS ,
91+ )
92+ except TypeError : # pragma: no cover - compatibility with older shared wheels
93+ localized = _base_localize_notification_text (text , translator = translator )
94+ if not _translator_uses_zh (translator ):
95+ return localized
96+ for source , target in _LONG_BRIDGE_ZH_NOTIFICATION_REPLACEMENTS :
97+ localized = localized .replace (source , target )
98+ return localized
99+
100+
101+ def _localize_source_input_status (status , * , translator ) -> str :
102+ value = str (status or "" ).strip ()
103+ if not value :
104+ return ""
105+ label = _SOURCE_INPUT_STATUS_LABELS .get (value )
106+ if label is not None :
107+ return label [0 ] if _translator_uses_zh (translator ) else label [1 ]
108+ if _translator_uses_zh (translator ):
109+ return _localize_notification_text (value , translator = translator )
110+ return value .replace ("_" , " " )
61111
62112
63113def _localize_timing_contract (contract : str , * , translator ) -> str :
@@ -205,6 +255,7 @@ def _format_source_input_line(snapshot, *, translator) -> str:
205255 price_as_of = str (snapshot .get ("price_as_of" ) or "" ).strip ()
206256 universe_as_of = str (snapshot .get ("universe_as_of" ) or "" ).strip ()
207257 status = str (snapshot .get ("source_input_status" ) or "" ).strip ()
258+ localized_status = _localize_source_input_status (status , translator = translator )
208259 fallback_used = _is_truthy (snapshot .get ("source_input_fallback_used" ))
209260 fallback_streak = snapshot .get ("source_input_fallback_streak" )
210261 if not price_as_of and not universe_as_of and not status and not fallback_used :
@@ -220,8 +271,8 @@ def _format_source_input_line(snapshot, *, translator) -> str:
220271 if fallback_streak not in (None , "" , 0 , "0" ):
221272 fallback_text += f" 连续{ fallback_streak } 次"
222273 parts .append (fallback_text )
223- elif status :
224- parts .append (f"状态 { status } " )
274+ elif localized_status :
275+ parts .append (f"状态 { localized_status } " )
225276 return "🧩 输入状态: " + " | " .join (parts )
226277 parts = []
227278 if price_as_of :
@@ -233,8 +284,8 @@ def _format_source_input_line(snapshot, *, translator) -> str:
233284 if fallback_streak not in (None , "" , 0 , "0" ):
234285 fallback_text += f" streak={ fallback_streak } "
235286 parts .append (fallback_text )
236- elif status :
237- parts .append (f"status { status } " )
287+ elif localized_status :
288+ parts .append (f"status { localized_status } " )
238289 return "🧩 Inputs: " + " | " .join (parts )
239290
240291
0 commit comments