From 35faa70e9cc8662891ca2c28d6ea11b09ea34e7e Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Tue, 11 Aug 2026 11:50:16 +0800 Subject: [PATCH] fix: localize main status and debug ribbon --- XP.Common/Resources/Resources.en-US.resx | 3 ++ XP.Common/Resources/Resources.resx | 3 ++ XP.Common/Resources/Resources.zh-CN.resx | 3 ++ XP.Common/Resources/Resources.zh-TW.resx | 3 ++ .../Main/RibbonStatusAreaViewModel.cs | 48 ++++++++++++------- XplorePlane/Views/Main/ImagePanelView.xaml | 7 +-- XplorePlane/Views/Main/MainWindow.xaml | 8 ++-- .../Views/Main/RibbonStatusAreaView.xaml | 3 +- 8 files changed, 52 insertions(+), 26 deletions(-) diff --git a/XP.Common/Resources/Resources.en-US.resx b/XP.Common/Resources/Resources.en-US.resx index b61d042c..e402489d 100644 --- a/XP.Common/Resources/Resources.en-US.resx +++ b/XP.Common/Resources/Resources.en-US.resx @@ -1,5 +1,8 @@  +ReportGenerate Report +Log inSuper AdministratorAdministratorUserLive PipelineCNC OrchestrationClose OrchestrationSoftware Info +Settings HomeFileNew CNCSave AsLoad CNCImport CNC PackageExport CNC PackageProgramRunStopLiveOpen DoorClose Door3D ScanScan ModeCT ScanHelpUser Manual LoggingX-ray SourceDetectorMotion ControlNavigation CameraAccounts and Passwords Lead Inspection Results diff --git a/XP.Common/Resources/Resources.resx b/XP.Common/Resources/Resources.resx index 401591e5..81274f26 100644 --- a/XP.Common/Resources/Resources.resx +++ b/XP.Common/Resources/Resources.resx @@ -1,5 +1,8 @@  + 报告报告生成 + 登录超级管理员管理员用户实时流水线CNC 编排关闭编排软件信息 + 设置 主页文件新建CNC另存为加载CNC导入CNC包导出CNC包程序运行停止实时开窗关窗3D扫描扫描模式CT扫描帮助用户手册 日志射线源探测器运动控制导航相机账户与密码 引脚检测结果 diff --git a/XP.Common/Resources/Resources.zh-CN.resx b/XP.Common/Resources/Resources.zh-CN.resx index 877839b7..734bb5a7 100644 --- a/XP.Common/Resources/Resources.zh-CN.resx +++ b/XP.Common/Resources/Resources.zh-CN.resx @@ -1,5 +1,8 @@  +报告报告生成 +登录超级管理员管理员用户实时流水线CNC 编排关闭编排软件信息 +设置 主页文件新建CNC另存为加载CNC导入CNC包导出CNC包程序运行停止实时开窗关窗3D扫描扫描模式CT扫描帮助用户手册 日志射线源探测器运动控制导航相机账户与密码 引脚检测结果 diff --git a/XP.Common/Resources/Resources.zh-TW.resx b/XP.Common/Resources/Resources.zh-TW.resx index 583b2598..8dd87a1d 100644 --- a/XP.Common/Resources/Resources.zh-TW.resx +++ b/XP.Common/Resources/Resources.zh-TW.resx @@ -1,5 +1,8 @@  +報告產生報告 +登入超級管理員管理員使用者即時流水線CNC 編排關閉編排軟體資訊 +設定 首頁檔案新增CNC另存新檔載入CNC匯入CNC套件匯出CNC套件程式執行停止即時開窗關窗3D掃描掃描模式CT掃描說明使用者手冊 日誌X光源探測器運動控制導航相機帳戶與密碼 引腳檢測結果 diff --git a/XplorePlane/ViewModels/Main/RibbonStatusAreaViewModel.cs b/XplorePlane/ViewModels/Main/RibbonStatusAreaViewModel.cs index 6ffb7ce3..0c1d898d 100644 --- a/XplorePlane/ViewModels/Main/RibbonStatusAreaViewModel.cs +++ b/XplorePlane/ViewModels/Main/RibbonStatusAreaViewModel.cs @@ -9,7 +9,9 @@ using System.Windows; using XplorePlane.Events; using XplorePlane.Services.AppState; using XplorePlane.Services.Security; -using XplorePlane.Views.Security; +using XplorePlane.Views.Security; +using XP.Common.Localization; +using XP.Common.Localization.Interfaces; namespace XplorePlane.ViewModels.Main { @@ -23,7 +25,8 @@ namespace XplorePlane.ViewModels.Main private readonly IPermissionService _permissionService; private readonly IEventAggregator _eventAggregator; private readonly IAppStateService _appStateService; - private readonly IContainerProvider _containerProvider; + private readonly IContainerProvider _containerProvider; + private readonly ILocalizationService _localizationService; private string _currentRoleDisplayName = string.Empty; private bool _canSwitchUser; @@ -47,20 +50,23 @@ namespace XplorePlane.ViewModels.Main public RibbonStatusAreaViewModel( IPermissionService permissionService, - IEventAggregator eventAggregator, - IAppStateService appStateService, - IContainerProvider containerProvider) + IEventAggregator eventAggregator, + IAppStateService appStateService, + IContainerProvider containerProvider, + ILocalizationService localizationService) { _permissionService = permissionService ?? throw new System.ArgumentNullException(nameof(permissionService)); _eventAggregator = eventAggregator ?? throw new System.ArgumentNullException(nameof(eventAggregator)); _appStateService = appStateService ?? throw new System.ArgumentNullException(nameof(appStateService)); - _containerProvider = containerProvider ?? throw new System.ArgumentNullException(nameof(containerProvider)); + _containerProvider = containerProvider ?? throw new System.ArgumentNullException(nameof(containerProvider)); + _localizationService = localizationService ?? throw new System.ArgumentNullException(nameof(localizationService)); SwitchUserCommand = new DelegateCommand(ExecuteSwitchUser, () => CanSwitchUser); // Subscribe to RoleChangedEvent to update CurrentRoleDisplayName - _eventAggregator.GetEvent() - .Subscribe(OnRoleChanged, ThreadOption.UIThread); + _eventAggregator.GetEvent() + .Subscribe(OnRoleChanged, ThreadOption.UIThread); + _localizationService.LanguageChanged += OnLanguageChanged; // Subscribe to CncExecutionState changes to update CanSwitchUser _appStateService.CncExecutionStateChanged += OnCncExecutionStateChanged; @@ -79,10 +85,16 @@ namespace XplorePlane.ViewModels.Main CanSwitchUser = _permissionService.CanSwitchUser; } - private void OnRoleChanged(RoleChangedPayload payload) + private void OnRoleChanged(RoleChangedPayload payload) { CurrentRoleDisplayName = MapRoleToDisplayName(payload.NewRole); - } + } + + private void OnLanguageChanged(object? sender, XP.Common.Localization.Events.LanguageChangedEventArgs e) + { + if (_permissionService.CurrentRole.HasValue) + CurrentRoleDisplayName = MapRoleToDisplayName(_permissionService.CurrentRole.Value); + } private void OnCncExecutionStateChanged(object sender, StateChangedEventArgs e) { @@ -117,15 +129,15 @@ namespace XplorePlane.ViewModels.Main /// /// 将 UserRole 枚举映射为中文显示名。 /// - private static string MapRoleToDisplayName(UserRole role) - { - return role switch - { - UserRole.SuperAdmin => "超级管理员", - UserRole.Admin => "管理员", - UserRole.User => "用户", + private static string MapRoleToDisplayName(UserRole role) + { + return role switch + { + UserRole.SuperAdmin => LocalizationHelper.Get("Role_SuperAdmin"), + UserRole.Admin => LocalizationHelper.Get("Role_Admin"), + UserRole.User => LocalizationHelper.Get("Role_User"), _ => string.Empty }; } } -} \ No newline at end of file +} diff --git a/XplorePlane/Views/Main/ImagePanelView.xaml b/XplorePlane/Views/Main/ImagePanelView.xaml index 7c7a81ad..d52c7d16 100644 --- a/XplorePlane/Views/Main/ImagePanelView.xaml +++ b/XplorePlane/Views/Main/ImagePanelView.xaml @@ -3,6 +3,7 @@ x:Name="Root" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:loc="clr-namespace:XP.Common.Localization.Extensions;assembly=XP.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="400" @@ -82,16 +83,16 @@ -