From 026d0a5e485c09afd77ff1447ee6dd36bd0325a1 Mon Sep 17 00:00:00 2001 From: mawei Date: Wed, 3 Jun 2026 09:57:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(i18n):=20=E5=B0=86=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=96=87=E5=AD=97=E7=BF=BB=E8=AF=91=E5=BB=B6=E8=BF=9F=E5=88=B0?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E6=97=B6=E6=89=A7=E8=A1=8C=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=AF=AD=E8=A8=80=E5=88=87=E6=8D=A2=E5=90=8E=E4=BB=8D?= =?UTF-8?q?=E6=98=AF=E8=8B=B1=E6=96=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PanelInfo 构造时调用 tr() 只会在模块加载时(默认 en)执行一次, 后续语言切换后 panel_info.name 不会自动更新。 将 NavButton._render() 中对 self.panel_info.name 的引用改为 tr(self.panel_info.name),在每次渲染时实时翻译。 --- selfdrive/ui/sunnypilot/layouts/settings/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/sunnypilot/layouts/settings/settings.py b/selfdrive/ui/sunnypilot/layouts/settings/settings.py index 2780c06c..fa8f5e0e 100644 --- a/selfdrive/ui/sunnypilot/layouts/settings/settings.py +++ b/selfdrive/ui/sunnypilot/layouts/settings/settings.py @@ -71,7 +71,7 @@ class NavButton(Widget): is_selected = self.panel_type == self.parent._current_panel text_color = OP.TEXT_SELECTED if is_selected else OP.TEXT_NORMAL content_x = rect.x + 90 - text_size = measure_text_cached(self.parent._font_medium, self.panel_info.name, 65) + text_size = measure_text_cached(self.parent._font_medium, tr(self.panel_info.name), 65) # Draw background if selected if is_selected: @@ -90,7 +90,7 @@ class NavButton(Widget): content_x, rect.y + (OP.NAV_BTN_HEIGHT - text_size.y) / 2 ) - rl.draw_text_ex(self.parent._font_medium, self.panel_info.name, text_pos, 55, 0, text_color) + rl.draw_text_ex(self.parent._font_medium, tr(self.panel_info.name), text_pos, 55, 0, text_color) # Store button rect for click detection self.panel_info.button_rect = rect