diff --git a/src/MetahookInstallerAvalonia/App.axaml.cs b/src/MetahookInstallerAvalonia/App.axaml.cs index b9022e3..208e4d8 100644 --- a/src/MetahookInstallerAvalonia/App.axaml.cs +++ b/src/MetahookInstallerAvalonia/App.axaml.cs @@ -7,11 +7,33 @@ using System; using System.Globalization; using System.IO; +using System.Linq; namespace MetahookInstallerAvalonia; public partial class App : Application { + // Ursa only ships en-US / fr-FR / zh-CN locale resources. Map the effective + // culture onto one of those: Chinese keeps zh-CN, French keeps fr-FR, and + // everything else (including the "no lang file" fallback) uses en-US so the + // built-in control strings start out in English rather than Ursa's zh-CN default. + private static string NormalizeUrsaLocale(string? lang) + { + if (string.IsNullOrEmpty(lang)) + { + return "en-US"; + } + if (lang.StartsWith("zh", StringComparison.OrdinalIgnoreCase)) + { + return "zh-CN"; + } + if (lang.StartsWith("fr", StringComparison.OrdinalIgnoreCase)) + { + return "fr-FR"; + } + return "en-US"; + } + public override void Initialize() { AvaloniaXamlLoader.Load(this); @@ -20,11 +42,21 @@ public override void Initialize() public override void OnFrameworkInitializationCompleted() { var settingPath = Path.Combine(".", "lang"); - if (File.Exists(settingPath)) + string? lang = File.Exists(settingPath) ? File.ReadAllText(settingPath).Trim() : null; + if (!string.IsNullOrEmpty(lang)) { - string lang = File.ReadAllText(settingPath); Lang.Resources.Culture = new CultureInfo(lang); } + + // Keep Ursa's built-in control strings (PopConfirm / MessageBox buttons, + // etc.) in sync with the installer language. Without this the theme keeps + // its zh-CN default and shows Chinese buttons in English mode. + var ursaTheme = Styles.OfType().FirstOrDefault(); + if (ursaTheme != null) + { + ursaTheme.Locale = new CultureInfo(NormalizeUrsaLocale(lang)); + } + var themePath = Path.Combine(".", "theme"); if (File.Exists(themePath)) { diff --git a/src/MetahookInstallerAvalonia/Lang/Resources.resx b/src/MetahookInstallerAvalonia/Lang/Resources.resx index 8c79fd6..79e03b7 100644 --- a/src/MetahookInstallerAvalonia/Lang/Resources.resx +++ b/src/MetahookInstallerAvalonia/Lang/Resources.resx @@ -169,19 +169,19 @@ Critical Error - The install/output folder cannot be located next to MetahookInstaller.exe. Please extract the complete archive before running the programme. + The install/output folder cannot be located next to MetahookInstaller.exe. Please extract the complete archive before running the program. - Invalid instal target. + Invalid install target. - Could not found {0}. + Could not find {0}. Warning - Failed when deleting {0}. Error message {1}. + Failed to delete {0}. Error message: {1}. Success! @@ -190,13 +190,13 @@ Uninstall finished. - Please install mod first. + Please install the mod first. - Install Mod finished! + Mod installed successfully! - Reset finished + Reset finished. Saved. @@ -208,13 +208,13 @@ 中文 - Confirmed to apply modification? + Apply this change? - Installing the new file will replace the original file, and this operation cannot be reversed. + Installing the new files will replace the original files. This action cannot be undone. - Uninstalling will remove all Metahook-related files, including the metahook folder, and this action cannot be reversed. + Uninstalling will remove all Metahook-related files, including the metahook folder. This action cannot be undone. Cancelled