add:i18n
This commit is contained in:
@@ -31,6 +31,11 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(cultureName))
|
||||||
|
{
|
||||||
|
CurrentCulture = CultureInfo.InstalledUICulture;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
var culture = CultureInfo.GetCultureInfo(cultureName);
|
var culture = CultureInfo.GetCultureInfo(cultureName);
|
||||||
CurrentCulture = culture;
|
CurrentCulture = culture;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -581,7 +581,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxStartup">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Startup_Start}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Startup_Start}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -710,7 +710,7 @@
|
|||||||
-->
|
-->
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxCanvas">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Canvas_GroupTitle}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Canvas_GroupTitle}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -926,7 +926,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<!-- 崩溃后操作设置 -->
|
<!-- 崩溃后操作设置 -->
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxCrashAction">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Crash_Title}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Crash_Title}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -944,7 +944,7 @@
|
|||||||
<TextBlock Text="{i18n:I18n Key=Crash_Hint}" Foreground="#a1a1aa" />
|
<TextBlock Text="{i18n:I18n Key=Crash_Hint}" Foreground="#a1a1aa" />
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxGesture">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Gesture_Title}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Gesture_Title}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -1517,7 +1517,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxPPT">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=PPT_GroupTitle}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=PPT_GroupTitle}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -2502,7 +2502,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
|
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxAdvanced">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Advanced_Title}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Advanced_Title}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -2887,7 +2887,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxAutomation">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Automation_Title}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Automation_Title}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
@@ -3959,7 +3959,7 @@
|
|||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</ui:SimpleStackPanel>
|
</ui:SimpleStackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
<GroupBox>
|
<GroupBox Name="GroupBoxAbout">
|
||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=About_Title}" FontWeight="Bold" Foreground="#fafafa"
|
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=About_Title}" FontWeight="Bold" Foreground="#fafafa"
|
||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Ink_Canvas.Windows;
|
|||||||
using iNKORE.UI.WPF.Modern;
|
using iNKORE.UI.WPF.Modern;
|
||||||
using iNKORE.UI.WPF.Modern.Controls;
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -68,6 +69,9 @@ namespace Ink_Canvas
|
|||||||
// 设置面板相关状态
|
// 设置面板相关状态
|
||||||
private bool isTemporarilyDisablingNoFocusMode = false;
|
private bool isTemporarilyDisablingNoFocusMode = false;
|
||||||
|
|
||||||
|
private bool _isApplyingLanguageFromSettings;
|
||||||
|
private bool _isReloadingForLanguageChange;
|
||||||
|
|
||||||
// 全屏处理状态标志
|
// 全屏处理状态标志
|
||||||
public bool isFullScreenApplied = false;
|
public bool isFullScreenApplied = false;
|
||||||
|
|
||||||
@@ -96,15 +100,21 @@ namespace Ink_Canvas
|
|||||||
*/
|
*/
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var preferredLanguage = Settings?.Appearance?.Language;
|
var path = App.RootPath + settingsFileName;
|
||||||
if (!string.IsNullOrWhiteSpace(preferredLanguage))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
LocalizationHelper.TrySetCulture(preferredLanguage);
|
var json = File.ReadAllText(path);
|
||||||
|
var loadedSettings = JsonConvert.DeserializeObject<Settings>(json);
|
||||||
|
var preferredLanguage = loadedSettings?.Appearance?.Language;
|
||||||
|
if (!string.IsNullOrWhiteSpace(preferredLanguage))
|
||||||
|
{
|
||||||
|
LocalizationHelper.TrySetCulture(preferredLanguage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"应用首选界面语言失败: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"启动时预加载语言失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -207,7 +217,6 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
CheckColorTheme(true);
|
CheckColorTheme(true);
|
||||||
CheckPenTypeUIState();
|
CheckPenTypeUIState();
|
||||||
ApplyLanguageFromSettings();
|
|
||||||
|
|
||||||
// 初始化墨迹平滑管理器
|
// 初始化墨迹平滑管理器
|
||||||
_inkSmoothingManager = new InkSmoothingManager(Dispatcher);
|
_inkSmoothingManager = new InkSmoothingManager(Dispatcher);
|
||||||
@@ -1169,6 +1178,7 @@ namespace Ink_Canvas
|
|||||||
loadPenCanvas();
|
loadPenCanvas();
|
||||||
//加载设置
|
//加载设置
|
||||||
LoadSettings(true);
|
LoadSettings(true);
|
||||||
|
ApplyLanguageFromSettings();
|
||||||
AutoBackupManager.Initialize(Settings);
|
AutoBackupManager.Initialize(Settings);
|
||||||
CheckUpdateChannelAndTelemetryConsistency();
|
CheckUpdateChannelAndTelemetryConsistency();
|
||||||
|
|
||||||
@@ -1513,7 +1523,15 @@ namespace Ink_Canvas
|
|||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBoxLanguage.SelectedIndex = index;
|
_isApplyingLanguageFromSettings = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ComboBoxLanguage.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isApplyingLanguageFromSettings = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -2520,28 +2538,28 @@ namespace Ink_Canvas
|
|||||||
switch (sectionTag.ToLower())
|
switch (sectionTag.ToLower())
|
||||||
{
|
{
|
||||||
case "startup":
|
case "startup":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "启动");
|
targetGroupBox = GroupBoxStartup;
|
||||||
break;
|
break;
|
||||||
case "canvas":
|
case "canvas":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "画板和墨迹");
|
targetGroupBox = GroupBoxCanvas;
|
||||||
break;
|
break;
|
||||||
case "gesture":
|
case "gesture":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "手势");
|
targetGroupBox = GroupBoxGesture;
|
||||||
break;
|
break;
|
||||||
case "inkrecognition":
|
case "inkrecognition":
|
||||||
targetGroupBox = GroupBoxInkRecognition;
|
targetGroupBox = GroupBoxInkRecognition;
|
||||||
break;
|
break;
|
||||||
case "crashaction":
|
case "crashaction":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "崩溃后操作");
|
targetGroupBox = GroupBoxCrashAction;
|
||||||
break;
|
break;
|
||||||
case "ppt":
|
case "ppt":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "PPT联动");
|
targetGroupBox = GroupBoxPPT;
|
||||||
break;
|
break;
|
||||||
case "advanced":
|
case "advanced":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "高级设置");
|
targetGroupBox = GroupBoxAdvanced;
|
||||||
break;
|
break;
|
||||||
case "automation":
|
case "automation":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "自动化");
|
targetGroupBox = GroupBoxAutomation;
|
||||||
break;
|
break;
|
||||||
case "randomwindow":
|
case "randomwindow":
|
||||||
targetGroupBox = GroupBoxRandWindow;
|
targetGroupBox = GroupBoxRandWindow;
|
||||||
@@ -2551,10 +2569,10 @@ namespace Ink_Canvas
|
|||||||
break;
|
break;
|
||||||
case "shortcuts":
|
case "shortcuts":
|
||||||
// 快捷键设置部分可能尚未实现
|
// 快捷键设置部分可能尚未实现
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "快捷键");
|
targetGroupBox = null;
|
||||||
break;
|
break;
|
||||||
case "about":
|
case "about":
|
||||||
targetGroupBox = FindGroupBoxByHeader(stackPanel, "关于");
|
targetGroupBox = GroupBoxAbout;
|
||||||
break;
|
break;
|
||||||
case "plugins":
|
case "plugins":
|
||||||
targetGroupBox = GroupBoxPlugins;
|
targetGroupBox = GroupBoxPlugins;
|
||||||
@@ -4554,6 +4572,8 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!isLoaded) return;
|
if (!isLoaded) return;
|
||||||
|
if (_isApplyingLanguageFromSettings) return;
|
||||||
|
if (_isReloadingForLanguageChange) return;
|
||||||
if (Settings?.Appearance == null) return;
|
if (Settings?.Appearance == null) return;
|
||||||
if (ComboBoxLanguage == null) return;
|
if (ComboBoxLanguage == null) return;
|
||||||
|
|
||||||
@@ -4577,11 +4597,9 @@ namespace Ink_Canvas
|
|||||||
Settings.Appearance.Language = language;
|
Settings.Appearance.Language = language;
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(language))
|
LocalizationHelper.TrySetCulture(language);
|
||||||
{
|
|
||||||
LocalizationHelper.TrySetCulture(language);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_isReloadingForLanguageChange = true;
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -4599,13 +4617,15 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"重建主窗口以应用语言时出错: {ex2.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"重建主窗口以应用语言时出错: {ex2.Message}", LogHelper.LogType.Error);
|
||||||
ShowNotification("已更新界面语言设置,重启应用后可完全生效。");
|
ShowNotification("已更新界面语言设置,重启应用后可完全生效。");
|
||||||
|
_isReloadingForLanguageChange = false;
|
||||||
}
|
}
|
||||||
}), DispatcherPriority.Normal);
|
}), DispatcherPriority.ApplicationIdle);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"切换界面语言时出错: {ex.Message}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"切换界面语言时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||||
ShowNotification("切换界面语言失败。");
|
ShowNotification("切换界面语言失败。");
|
||||||
|
_isReloadingForLanguageChange = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,22 @@ namespace Ink_Canvas
|
|||||||
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Settings?.Appearance != null)
|
||||||
|
{
|
||||||
|
var preferredLanguage = Settings.Appearance.Language ?? string.Empty;
|
||||||
|
if (!string.IsNullOrWhiteSpace(preferredLanguage))
|
||||||
|
{
|
||||||
|
LocalizationHelper.TrySetCulture(preferredLanguage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.WriteLogToFile($"从配置应用界面语言失败: {ex.Message}", LogHelper.LogType.Error);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProcessProtectionManager.ApplyFromSettings();
|
ProcessProtectionManager.ApplyFromSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user