diff --git a/ExplorerTabUtility/App.xaml.cs b/ExplorerTabUtility/App.xaml.cs index ff68cfe..c3fa3f9 100644 --- a/ExplorerTabUtility/App.xaml.cs +++ b/ExplorerTabUtility/App.xaml.cs @@ -3,6 +3,7 @@ using System.Windows.Controls; using ExplorerTabUtility.UI.Views; using ExplorerTabUtility.Helpers; +using ExplorerTabUtility.Languages.Manager; namespace ExplorerTabUtility; @@ -24,10 +25,7 @@ protected override void OnStartup(StartupEventArgs e) return; } - CustomMessageBox.Show(""" - Another instance is already running. - Check in System Tray Icons. - """, Constants.AppName, icon: MessageBoxImage.Information); + CustomMessageBox.Show(LangeuageHelper.Instance.LanguageFields.AlreadyRunning, Constants.AppName, icon: MessageBoxImage.Information); Shutdown(); } diff --git a/ExplorerTabUtility/ExplorerTabUtility.csproj b/ExplorerTabUtility/ExplorerTabUtility.csproj index b8d9016..05c61b0 100644 --- a/ExplorerTabUtility/ExplorerTabUtility.csproj +++ b/ExplorerTabUtility/ExplorerTabUtility.csproj @@ -20,16 +20,16 @@ - - - - - + + + + + - - + + @@ -54,7 +54,16 @@ - + + + + + + PreserveNewest + + + PreserveNewest + diff --git a/ExplorerTabUtility/Helpers/Constants.cs b/ExplorerTabUtility/Helpers/Constants.cs index 03277e7..4e4085d 100644 --- a/ExplorerTabUtility/Helpers/Constants.cs +++ b/ExplorerTabUtility/Helpers/Constants.cs @@ -4,10 +4,8 @@ internal static class Constants { internal const string AppName = "ExplorerTabUtility"; internal const string MutexId = $"__{AppName}Hook__Mutex"; - internal const string NotifyIconText = "Explorer Tab Utility: Force new windows to tabs."; internal const string SettingsFileName = "settings.json"; internal const string HotKeyProfilesFileName = "HotKeyProfiles.json"; - internal const string JsonFileFilter = "JSON files (*.json)|*.json|All Files|*.*"; internal const string UpdateUrl = "https://api.github.com/repos/w4po/ExplorerTabUtility/releases/latest"; internal const string DefaultHotKeyProfiles = "[{\"Name\":\"Home\",\"HotKeys\":[91,69],\"Scope\":0,\"Action\":0,\"Path\":\"\",\"IsHandled\":true,\"IsEnabled\":true,\"Delay\":0},{\"Name\":\"Duplicate\",\"HotKeys\":[17,68],\"Scope\":1,\"Action\":1,\"Path\":null,\"IsHandled\":true,\"IsEnabled\":true,\"Delay\":0},{\"Name\":\"ReopenClosed\",\"HotKeys\":[16,17,84],\"Scope\":1,\"Action\":2,\"Path\":null,\"IsHandled\":true,\"IsEnabled\":true,\"Delay\":0}]"; } \ No newline at end of file diff --git a/ExplorerTabUtility/Hooks/ExplorerWatcher.cs b/ExplorerTabUtility/Hooks/ExplorerWatcher.cs index 0c71a89..c8a93e2 100644 --- a/ExplorerTabUtility/Hooks/ExplorerWatcher.cs +++ b/ExplorerTabUtility/Hooks/ExplorerWatcher.cs @@ -15,6 +15,7 @@ using ExplorerTabUtility.Models; using ExplorerTabUtility.WinAPI; using ExplorerTabUtility.UI.Views; +using ExplorerTabUtility.Languages.Manager; namespace ExplorerTabUtility.Hooks; @@ -523,7 +524,7 @@ private void RemoveWindowAndUnhookEvents(InternetExplorer window, WindowInfo win private async Task RestorePreviousWindows() { var result = await RunInStaThread(() => CustomMessageBox.Show( - "Do you want to restore previously opened windows?", + LangeuageHelper.Instance.LanguageFields.RestorePreviouslyOpenedWindows, "Explorer Tab Utility", MessageBoxButton.YesNo, MessageBoxImage.Question)); diff --git a/ExplorerTabUtility/Languages/Manager/LangeuageHelper.cs b/ExplorerTabUtility/Languages/Manager/LangeuageHelper.cs new file mode 100644 index 0000000..c7eb69c --- /dev/null +++ b/ExplorerTabUtility/Languages/Manager/LangeuageHelper.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ExplorerTabUtility.Managers; +using ExplorerTabUtility.Models; + +namespace ExplorerTabUtility.Languages.Manager +{ + internal class LangeuageHelper + { + #region 属性 + /// + /// 单例 + /// + public static LangeuageHelper Instance { get; } = new LangeuageHelper(); + + /// + /// 语言字段 + /// + public LanguageFields LanguageFields { get; private set; } + + /// + /// 语言集合 + /// + public List Languages { get; private set; } + + private ComboBoxItemInfo currentLanguage; + /// + /// 当前语言 + /// + public ComboBoxItemInfo CurrentLanguage + { + get { return currentLanguage; } + set + { + var change = LoadLanguage(value.Key); + if (change) + { + SettingsManager.Language = value.Key; + currentLanguage = value; + } + else + { + change = LoadLanguage(currentLanguage.Key); + } + + if (change) OnLangeuageChanged?.Invoke(); + } + } + #endregion + + #region 事件 + public event Action? OnLangeuageChanged; + #endregion + + private readonly string languageDir = "Languages"; + + private LangeuageHelper() + { + LanguageFields = new LanguageFields(); + Languages = GetLanguages(); + + var language = SettingsManager.Language ?? "en-US"; + currentLanguage = Languages.FirstOrDefault(t => t.Key == language) ?? Languages.First(); + LoadLanguage(currentLanguage.Key); + } + + #region 语言相关方法 + private List GetLanguages() + { + if (Directory.Exists(languageDir) == false) + { + return GetDefaultLanguages(); + } + + try + { + var filePaths = Directory.GetFiles(languageDir, "*.txt"); + if (filePaths.Length == 0) + { + return GetDefaultLanguages(); + } + else + { + var result = new List(filePaths.Length); + foreach (var item in filePaths) + { + result.Add(GetLanguage(item)); + } + return result; + } + } + catch (Exception) + { + return GetDefaultLanguages(); + } + } + + private List GetDefaultLanguages() + { + return new List + { + new ComboBoxItemInfo("en-US","English"), + }; + } + + private ComboBoxItemInfo GetLanguage(string filePath) + { + var code = Path.GetFileNameWithoutExtension(filePath); + var name = code; + + try + { + var languageName = nameof(LanguageFields.LanguageName); + foreach (var line in File.ReadLines(filePath)) + { + if (GetKeyValue(line, out var key, out var value) && key == languageName) + { + name = value; + break; + } + } + } + catch (Exception) + { + } + + return new ComboBoxItemInfo(code, name); + } + + private bool LoadLanguage(string langeuage) + { + try + { + LanguageFields.ResetLanguageFields(); + + var filePath = Path.Combine(languageDir, $"{langeuage}.txt"); + if (File.Exists(filePath) == false) return false; + + foreach (var line in File.ReadLines(filePath)) + { + if (GetKeyValue(line, out var key, out var value)) + { + LanguageFields.SetValue(key, value); + } + } + } + catch (Exception) + { + return false; + } + + LanguageFields.RaiseAllPropertyChanged(); + return true; + } + + private bool GetKeyValue(string line, out string key, out string value) + { + if (string.IsNullOrWhiteSpace(line) || line.StartsWith("//")) + { + key = string.Empty; + value = string.Empty; + return false; + } + + var index = line.IndexOf(':'); + if (index < 1) + { + key = string.Empty; + value = string.Empty; + return false; + } + + key = line.Substring(0, index).Trim(); + value = line.Substring(index + 1).Replace("\\r\\n", "\\n").Replace("\\r", "\\n").Replace("\\n", Environment.NewLine); + return true; + } + #endregion + } +} diff --git a/ExplorerTabUtility/Languages/Manager/LanguageFields.cs b/ExplorerTabUtility/Languages/Manager/LanguageFields.cs new file mode 100644 index 0000000..1deec8a --- /dev/null +++ b/ExplorerTabUtility/Languages/Manager/LanguageFields.cs @@ -0,0 +1,1031 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using ExplorerTabUtility.Models; + +namespace ExplorerTabUtility.Languages.Manager +{ + /// + /// 语言字段类 + /// + internal class LanguageFields : BindableBase + { + class Field + { + public string DefaultValue { get; private set; } + public string? Value { get; set; } + + public Field(string defaultValue) + { + DefaultValue = defaultValue; + } + } + + private readonly Dictionary dictCurrentLanguageFields = new Dictionary(); + + #region 语言字段属性 + #region 语言信息 + /// + /// 语言名称 + /// + public string LanguageName { get => Get(); set => Set(value); } + private string languageNameDefaultValue = "English"; + #endregion + + #region 文件筛选 + /// + /// Json文件 + /// + public string JsonFiles { get => Get(); set => Set(value); } + private string jsonFilesDefaultValue = "JSON files (*.json)"; + + /// + /// 所有文件 + /// + public string AllFiles { get => Get(); set => Set(value); } + private string allFilesDefaultValue = "All Files"; + #endregion + + #region 快捷键菜单 + /// + /// 快捷键 + /// + public string Shortcuts { get => Get(); set => Set(value); } + private string shortcutsDefaultValue = "Shortcuts"; + + /// + /// 快捷键提示 + /// + public string ShortcutsToolTip { get => Get(); set => Set(value); } + private string shortcutsToolTipDefaultValue = "Configure keyboard and mouse shortcuts"; + + /// + /// 打开程序菜单 + /// + public string OpenApplicationMenu { get => Get(); set => Set(value); } + private string openApplicationMenuDefaultValue = "Open application menu"; + + /// + /// 添加 + /// + public string New { get => Get(); set => Set(value); } + private string newDefaultValue = "NEW"; + + /// + /// 添加提示 + /// + public string NewToolTip { get => Get(); set => Set(value); } + private string newToolTipDefaultValue = "Create a new profile"; + + /// + /// 导入 + /// + public string Import { get => Get(); set => Set(value); } + private string importDefaultValue = "IMPORT"; + + /// + /// 导入提示 + /// + public string ImportToolTip { get => Get(); set => Set(value); } + private string importToolTipDefaultValue = "Import profiles from a file"; + + /// + /// 导出 + /// + public string Export { get => Get(); set => Set(value); } + private string exportDefaultValue = "EXPORT"; + + /// + /// 导出提示 + /// + public string ExportToolTip { get => Get(); set => Set(value); } + private string exportToolTipDefaultValue = "Export profiles to a file"; + + /// + /// 保存 + /// + public string Save { get => Get(); set => Set(value); } + private string saveDefaultValue = "SAVE"; + + /// + /// 保存提示 + /// + public string SaveToolTip { get => Get(); set => Set(value); } + private string saveToolTipDefaultValue = "Persist all profile changes"; + + /// + /// 自动保存 + /// + public string AutoSave { get => Get(); set => Set(value); } + private string autoSaveDefaultValue = "Auto save"; + + /// + /// 自动保存提示 + /// + public string AutoSaveToolTip { get => Get(); set => Set(value); } + private string autoSaveToolTipDefaultValue = "Automatically save profiles when closing the window"; + #endregion + + #region 偏好菜单 + /// + /// 偏好 + /// + public string Preferences { get => Get(); set => Set(value); } + private string preferencesDefaultValue = "Preferences"; + + /// + /// 偏好提示 + /// + public string PreferencesToolTip { get => Get(); set => Set(value); } + private string preferencesToolTipDefaultValue = "Configure application settings"; + + /// + /// 程序设置 + /// + public string ApplicationSettings { get => Get(); set => Set(value); } + private string applicationSettingsDefaultValue = "Application Settings"; + + /// + /// 自动更新 + /// + public string AutoUpdate { get => Get(); set => Set(value); } + private string autoUpdateDefaultValue = "Auto update"; + + /// + /// 自动更新提示 + /// + public string AutoUpdateToolTip { get => Get(); set => Set(value); } + private string autoUpdateToolTipDefaultValue = "Automatically check for updates on startup"; + + /// + /// 我有主题问题 + /// + public string ThemeIssue { get => Get(); set => Set(value); } + private string themeIssueDefaultValue = "I have theme issues"; + + /// + /// 我有主题问题提示 + /// + public string ThemeIssueToolTip { get => Get(); set => Set(value); } + private string themeIssueToolTipDefaultValue = "Use alternative window hiding method that preserves your custom File-Explorer theme. Enable this if you have theme-related issues"; + + /// + /// 保存关闭历史 + /// + public string SaveClosedHistory { get => Get(); set => Set(value); } + private string saveClosedHistoryDefaultValue = "Save closed history"; + + /// + /// 保存关闭历史提示 + /// + public string SaveClosedHistoryToolTip { get => Get(); set => Set(value); } + private string saveClosedHistoryToolTipDefaultValue = "Save closed windows history so you can reopen them later (ReopenClosed, Tab search)"; + + /// + /// 恢复窗口 + /// + public string RestorePreviousWindows { get => Get(); set => Set(value); } + private string restorePreviousWindowsDefaultValue = "Restore previous windows"; + + /// + /// 恢复窗口提示 + /// + public string RestorePreviousWindowsToolTip { get => Get(); set => Set(value); } + private string restorePreviousWindowsToolTipDefaultValue = "Restore previously opened windows after restart or crash"; + + /// + /// 隐藏托盘图标 + /// + public string HideTrayIcon { get => Get(); set => Set(value); } + private string hideTrayIconDefaultValue = "Hide tray icon"; + + /// + /// 隐藏托盘图标提示 + /// + public string HideTrayIconToolTip { get => Get(); set => Set(value); } + private string hideTrayIconToolTipDefaultValue = "Hide the system tray icon"; + + /// + /// 选择语言 + /// + public string SelectLanguage { get => Get(); set => Set(value); } + private string selectLanguageDefaultValue = "Language"; + + /// + /// 选择语言提示 + /// + public string SelectLanguageToolTip { get => Get(); set => Set(value); } + private string selectLanguageToolTipDefaultValue = "Select Language"; + #endregion + + #region 关于菜单 + /// + /// 关于 + /// + public string About { get => Get(); set => Set(value); } + private string aboutDefaultValue = "About"; + + /// + /// 关于提示 + /// + public string AboutToolTip { get => Get(); set => Set(value); } + private string aboutToolTipDefaultValue = "About the application and support options"; + + /// + /// 简介 + /// + public string Profile { get => Get(); set => Set(value); } + private string profileDefaultValue = "Enhance your Windows File Explorer experience"; + + /// + /// 星标 + /// + public string Star { get => Get(); set => Set(value); } + private string starDefaultValue = "Star on GitHub"; + + /// + /// 支持项目 + /// + public string SupportProject { get => Get(); set => Set(value); } + private string supportProjectDefaultValue = "Support the Project"; + + /// + /// 支持项目文本 + /// + public string SupportProjectText { get => Get(); set => Set(value); } + private string supportProjectTextDefaultValue = "If you find this utility helpful, consider supporting its development through one of these options:"; + + /// + /// 赞助 + /// + public string GitHubSponsors { get => Get(); set => Set(value); } + private string gitHubSponsorsDefaultValue = "GitHub Sponsors"; + + /// + /// 众筹 + /// + public string Patreon { get => Get(); set => Set(value); } + private string patreonDefaultValue = "Patreon"; + + /// + /// 请我喝杯咖啡 + /// + public string Coffee { get => Get(); set => Set(value); } + private string coffeeDefaultValue = "Buy Me A Coffee"; + + /// + /// 付款 + /// + public string PayPal { get => Get(); set => Set(value); } + private string payPalDefaultValue = "PayPal"; + + /// + /// 开发者 + /// + public string Developer { get => Get(); set => Set(value); } + private string developerDefaultValue = "Developer"; + + /// + /// 支持者 + /// + public string Supporters { get => Get(); set => Set(value); } + private string supportersDefaultValue = "Current Supporters"; + + /// + /// 支持者文本 + /// + public string SupportersText { get => Get(); set => Set(value); } + private string supportersTextDefaultValue = "Thank you to all the amazing people who support this project!"; + + /// + /// 成为第一个支持者 + /// + public string FirstSupport { get => Get(); set => Set(value); } + private string firstSupportDefaultValue = "Be the first to support this project!"; + + /// + /// 支持的意义 + /// + public string SupportMeaning { get => Get(); set => Set(value); } + private string supportMeaningDefaultValue = "Your support helps keep this project alive"; + #endregion + + #region 任务栏菜单 + /// + /// 通知图标提示 + /// + public string NotifyIconText { get => Get(); set => Set(value); } + private string notifyIconTextDefaultValue = "Explorer Tab Utility: Force new windows to tabs."; + + /// + /// 键盘钩子 + /// + public string KeyboardHook { get => Get(); set => Set(value); } + private string keyboardHookDefaultValue = "Keyboard Hook"; + + /// + /// 键盘钩子提示 + /// + public string KeyboardHookToolTip { get => Get(); set => Set(value); } + private string keyboardHookToolTipDefaultValue = "Enable or disable keyboard shortcuts"; + + /// + /// 鼠标钩子 + /// + public string MouseHook { get => Get(); set => Set(value); } + private string mouseHookDefaultValue = "Mouse Hook"; + + /// + /// 鼠标钩子提示 + /// + public string MouseHookToolTip { get => Get(); set => Set(value); } + private string mouseHookToolTipDefaultValue = "Enable or disable mouse shortcuts"; + + /// + /// 资源管理器钩子 + /// + public string WindowHook { get => Get(); set => Set(value); } + private string windowHookDefaultValue = "Window Hook"; + + /// + /// 资源管理器钩子提示 + /// + public string WindowHookToolTip { get => Get(); set => Set(value); } + private string windowHookToolTipDefaultValue = "Toggle automatic redirection of new Explorer windows to tabs"; + + /// + /// 重用标签页 + /// + public string ReuseTabs { get => Get(); set => Set(value); } + private string reuseTabsDefaultValue = "Reuse Tabs"; + + /// + /// 重用标签页提示 + /// + public string ReuseTabsToolTip { get => Get(); set => Set(value); } + private string reuseTabsToolTipDefaultValue = "When enabled, navigates to existing tabs instead of opening duplicate tabs"; + + /// + /// 开机启动 + /// + public string AddToStartup { get => Get(); set => Set(value); } + private string addToStartupDefaultValue = "Add to startup"; + + /// + /// 开机启动提示 + /// + public string AddToStartupToolTip { get => Get(); set => Set(value); } + private string addToStartupToolTipDefaultValue = "Automatically start Explorer Tab Utility when Windows starts"; + + /// + /// 检查更新 + /// + public string CheckForUpdates { get => Get(); set => Set(value); } + private string checkForUpdatesDefaultValue = "Check for updates"; + + /// + /// 检查更新提示 + /// + public string CheckForUpdatesToolTip { get => Get(); set => Set(value); } + private string checkForUpdatesToolTipDefaultValue = "Check if a newer version of Explorer Tab Utility is available"; + + /// + /// 设置 + /// + public string Settings { get => Get(); set => Set(value); } + private string settingsDefaultValue = "Settings"; + + /// + /// 设置提示 + /// + public string SettingsToolTip { get => Get(); set => Set(value); } + private string settingsToolTipDefaultValue = "Open the settings window to configure the application"; + + /// + /// 退出 + /// + public string Exit { get => Get(); set => Set(value); } + private string exitDefaultValue = "Exit"; + + /// + /// 退出提示 + /// + public string ExitToolTip { get => Get(); set => Set(value); } + private string exitToolTipDefaultValue = "Close Explorer Tab Utility and stop all hooks"; + #endregion + + #region 快捷键配置控件 + /// + /// 启用提示 + /// + public string EnabledToolTip { get => Get(); set => Set(value); } + private string enabledToolTipDefaultValue = "Enable or disable this profile"; + + /// + /// 配置名称 + /// + public string Name { get => Get(); set => Set(value); } + private string nameDefaultValue = "Name"; + + /// + /// 配置名称提示 + /// + public string NameToolTip { get => Get(); set => Set(value); } + private string nameToolTipDefaultValue = "Name of the profile"; + + /// + /// 快捷键 + /// + public string Hotkeys { get => Get(); set => Set(value); } + private string hotkeysDefaultValue = "Hotkeys"; + + /// + /// 快捷键提示 + /// + public string HotkeysToolTip { get => Get(); set => Set(value); } + private string hotkeysToolTipDefaultValue = "Keyboard or mouse keys to listen for. Click to record a new key combination."; + + /// + /// 快捷键作用范围提示 + /// + public string ScopeToolTip { get => Get(); set => Set(value); } + private string scopeToolTipDefaultValue = "Scope of the hotkeys: Global (anywhere) or only when File Explorer is focused"; + + /// + /// 快捷键操作提示 + /// + public string ActionToolTip { get => Get(); set => Set(value); } + private string actionToolTipDefaultValue = "Action to perform when the hotkeys are pressed"; + + /// + /// 显示更多配置提示 + /// + public string ExpanderToggleToolTip { get => Get(); set => Set(value); } + private string expanderToggleToolTipDefaultValue = "Show more options"; + + /// + /// 删除配置提示 + /// + public string DeleteToolTip { get => Get(); set => Set(value); } + private string deleteToolTipDefaultValue = "Delete this profile"; + + /// + /// 路径 + /// + public string Path { get => Get(); set => Set(value); } + private string pathDefaultValue = "Location"; + + /// + /// 路径提示 + /// + public string PathToolTip { get => Get(); set => Set(value); } + private string pathToolTipDefaultValue = "Path to open when the hotkeys are pressed. (folder, file, website, CLSID)"; + + /// + /// 延迟 + /// + public string Delay { get => Get(); set => Set(value); } + private string delayDefaultValue = "Delay"; + + /// + /// 延迟提示 + /// + public string DelayToolTip { get => Get(); set => Set(value); } + private string delayToolTipDefaultValue = "Delay in milliseconds before performing the action"; + + /// + /// 已处理 + /// + public string Handled { get => Get(); set => Set(value); } + private string handledDefaultValue = "Handled"; + + /// + /// 已处理提示 + /// + public string HandledToolTip { get => Get(); set => Set(value); } + private string handledToolTipDefaultValue = "Prevent further processing of the hotkeys in other applications"; + + /// + /// 标签页 + /// + public string OpenAsTab { get => Get(); set => Set(value); } + private string openAsTabDefaultValue = "Tab"; + + /// + /// 标签页提示 + /// + public string OpenAsTabToolTip { get => Get(); set => Set(value); } + private string openAsTabToolTipDefaultValue = "Open as tab instead of a new window"; + #endregion + + #region 自定义消息弹窗控件 + /// + /// 确定 + /// + public string Ok { get => Get(); set => Set(value); } + private string okDefaultValue = "OK"; + + /// + /// 取消 + /// + public string Cancel { get => Get(); set => Set(value); } + private string cancelDefaultValue = "Cancel"; + + /// + /// 是 + /// + public string Yes { get => Get(); set => Set(value); } + private string yesDefaultValue = "Yes"; + + /// + /// 否 + /// + public string No { get => Get(); set => Set(value); } + private string noDefaultValue = "No"; + #endregion + + #region 标签页搜索控件 + /// + /// 清除提示 + /// + public string ClearToolTip { get => Get(); set => Set(value); } + private string clearToolTipDefaultValue = "Clear closed windows history"; + #endregion + + #region 提示消息 + /// + /// 程序已运行时的提示消息 + /// + public string AlreadyRunning { get => Get(); set => Set(value); } + private string alreadyRunningDefaultValue = $"Another instance is already running.{Environment.NewLine}Check in System Tray Icons."; + + /// + /// 恢复窗口时的提示消息 + /// + public string RestorePreviouslyOpenedWindows { get => Get(); set => Set(value); } + private string restorePreviouslyOpenedWindowsDefaultValue = "Do you want to restore previously opened windows?"; + + /// + /// 已设置快捷键时隐藏托盘图标的提示消息 + /// + public string HideTrayIconWithHotkeys { get => Get(); set => Set(value); } + private string hideTrayIconWithHotkeysDefaultValue = "You can show the app again by pressing {0}"; + + /// + /// 未设置快捷键时隐藏托盘图标的提示消息 + /// + public string HideTrayIconWithOutHotkeys { get => Get(); set => Set(value); } + private string hideTrayIconWithOutHotkeysDefaultValue = "Cannot hide tray icon if no hotkey is configured to toggle visibility."; + + /// + /// 清除历史记录的提示消息 + /// + public string ConfirmClearHistory { get => Get(); set => Set(value); } + private string confirmClearHistoryDefaultValue = "Are you sure you want to clear the closed windows history?"; + + /// + /// 清除历史记录的消息标题 + /// + public string ConfirmClearHistoryTitle { get => Get(); set => Set(value); } + private string confirmClearHistoryTitleDefaultValue = "Confirm Clear History"; + #endregion + + #region HotkeyScope枚举 + /// + /// 全局 + /// + public string Global { get => Get(); set => Set(value); } + private string globalDefaultValue = "Global"; + + /// + /// 资源管理器 + /// + public string FileExplorer { get => Get(); set => Set(value); } + private string fileExplorerDefaultValue = "FileExplorer"; + #endregion + + #region HotKeyAction枚举 + /// + /// 打开 + /// + public string Open { get => Get(); set => Set(value); } + private string openDefaultValue = "Open"; + + /// + /// 打开提示 + /// + public string OpenToolTip { get => Get(); set => Set(value); } + private string openToolTipDefaultValue = "Open a new tab/window with the specified location."; + + /// + /// 重复 + /// + public string Duplicate { get => Get(); set => Set(value); } + private string duplicateDefaultValue = "Duplicate"; + + /// + /// 重复提示 + /// + public string DuplicateToolTip { get => Get(); set => Set(value); } + private string duplicateToolTipDefaultValue = "Duplicate the current tab."; + + /// + /// 重新打开 + /// + public string ReopenClosed { get => Get(); set => Set(value); } + private string reopenClosedDefaultValue = "ReopenClosed"; + + /// + /// 重新打开提示 + /// + public string ReopenClosedToolTip { get => Get(); set => Set(value); } + private string reopenClosedToolTipDefaultValue = "Reopen the last closed location."; + + /// + /// 标签页搜索 + /// + public string TabSearch { get => Get(); set => Set(value); } + private string tabSearchDefaultValue = "TabSearch"; + + /// + /// 标签页搜索提示 + /// + public string TabSearchToolTip { get => Get(); set => Set(value); } + private string tabSearchToolTipDefaultValue = "Open tab search popup to find and switch between tabs."; + + /// + /// 后退 + /// + public string NavigateBack { get => Get(); set => Set(value); } + private string navigateBackDefaultValue = "NavigateBack"; + + /// + /// 后退提示 + /// + public string NavigateBackToolTip { get => Get(); set => Set(value); } + private string navigateBackToolTipDefaultValue = "Navigate back."; + + /// + /// 父目录 + /// + public string NavigateUp { get => Get(); set => Set(value); } + private string navigateUpDefaultValue = "NavigateUp"; + + /// + /// 父目录提示 + /// + public string NavigateUpToolTip { get => Get(); set => Set(value); } + private string navigateUpToolTipDefaultValue = "Navigate up."; + + /// + /// 前进 + /// + public string NavigateForward { get => Get(); set => Set(value); } + private string navigateForwardDefaultValue = "NavigateForward"; + + /// + /// 前进提示 + /// + public string NavigateForwardToolTip { get => Get(); set => Set(value); } + private string navigateForwardToolTipDefaultValue = "Navigate forward."; + + /// + /// 标记窗口 + /// + public string SetTargetWindow { get => Get(); set => Set(value); } + private string setTargetWindowDefaultValue = "SetTargetWindow"; + + /// + /// 标记窗口提示 + /// + public string SetTargetWindowToolTip { get => Get(); set => Set(value); } + private string setTargetWindowToolTipDefaultValue = "Mark the window that will receive the new tabs."; + + /// + /// 资源管理器 + /// + public string ToggleWinHook { get => Get(); set => Set(value); } + private string toggleWinHookDefaultValue = "ToggleWinHook"; + + /// + /// 资源管理器提示 + /// + public string ToggleWinHookToolTip { get => Get(); set => Set(value); } + private string toggleWinHookToolTipDefaultValue = "Toggle the window hook."; + + /// + /// 重用标签页 + /// + public string ToggleReuseTabs { get => Get(); set => Set(value); } + private string toggleReuseTabsDefaultValue = "ToggleReuseTabs"; + + /// + /// 重用标签页提示 + /// + public string ToggleReuseTabsToolTip { get => Get(); set => Set(value); } + private string toggleReuseTabsToolTipDefaultValue = "Toggle the reuse tabs option."; + + /// + /// 程序显隐 + /// + public string ToggleVisibility { get => Get(); set => Set(value); } + private string toggleVisibilityDefaultValue = "ToggleVisibility"; + + /// + /// 程序显隐提示 + /// + public string ToggleVisibilityToolTip { get => Get(); set => Set(value); } + private string toggleVisibilityToolTipDefaultValue = "Show/Hide the app."; + + /// + /// 分离标签 + /// + public string DetachTab { get => Get(); set => Set(value); } + private string detachTabDefaultValue = "DetachTab"; + + /// + /// 分离标签提示 + /// + public string DetachTabToolTip { get => Get(); set => Set(value); } + private string detachTabToolTipDefaultValue = "Detach the current tab."; + + /// + /// 右贴靠 + /// + public string SnapRight { get => Get(); set => Set(value); } + private string snapRightDefaultValue = "SnapRight"; + + /// + /// 右贴靠提示 + /// + public string SnapRightToolTip { get => Get(); set => Set(value); } + private string snapRightToolTipDefaultValue = "Snap the current window to the right."; + + /// + /// 左贴靠 + /// + public string SnapLeft { get => Get(); set => Set(value); } + private string snapLeftDefaultValue = "SnapLeft"; + + /// + /// 左贴靠提示 + /// + public string SnapLeftToolTip { get => Get(); set => Set(value); } + private string snapLeftToolTipDefaultValue = "Snap the current window to the left."; + + /// + /// 上贴靠 + /// + public string SnapUp { get => Get(); set => Set(value); } + private string snapUpDefaultValue = "SnapUp"; + + /// + /// 上贴靠提示 + /// + public string SnapUpToolTip { get => Get(); set => Set(value); } + private string snapUpToolTipDefaultValue = "Snap the current window to the top."; + + /// + /// 底贴靠 + /// + public string SnapDown { get => Get(); set => Set(value); } + private string snapDownDefaultValue = "SnapDown"; + + /// + /// 底贴靠提示 + /// + public string SnapDownToolTip { get => Get(); set => Set(value); } + private string snapDownToolTipDefaultValue = "Snap the current window to the bottom."; + #endregion + #endregion + + public LanguageFields() + { + InitLanguageFields(); + } + + #region 语言字典相关方法 + /// + /// 重置语言字段 + /// + public void ResetLanguageFields() + { + foreach (var item in dictCurrentLanguageFields.Values) + { + item.Value = null; + } + } + + /// + /// 初始化语言字段 + /// + private void InitLanguageFields() + { + //语言信息 + dictCurrentLanguageFields[nameof(LanguageName)] = new Field(languageNameDefaultValue); + + //文件筛选 + dictCurrentLanguageFields[nameof(JsonFiles)] = new Field(jsonFilesDefaultValue); + dictCurrentLanguageFields[nameof(AllFiles)] = new Field(allFilesDefaultValue); + + //快捷键菜单 + dictCurrentLanguageFields[nameof(Shortcuts)] = new Field(shortcutsDefaultValue); + dictCurrentLanguageFields[nameof(ShortcutsToolTip)] = new Field(shortcutsToolTipDefaultValue); + dictCurrentLanguageFields[nameof(OpenApplicationMenu)] = new Field(openApplicationMenuDefaultValue); + dictCurrentLanguageFields[nameof(New)] = new Field(newDefaultValue); + dictCurrentLanguageFields[nameof(NewToolTip)] = new Field(newToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Import)] = new Field(importDefaultValue); + dictCurrentLanguageFields[nameof(ImportToolTip)] = new Field(importToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Export)] = new Field(exportDefaultValue); + dictCurrentLanguageFields[nameof(ExportToolTip)] = new Field(exportToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Save)] = new Field(saveDefaultValue); + dictCurrentLanguageFields[nameof(SaveToolTip)] = new Field(saveToolTipDefaultValue); + dictCurrentLanguageFields[nameof(AutoSave)] = new Field(autoSaveDefaultValue); + dictCurrentLanguageFields[nameof(AutoSaveToolTip)] = new Field(autoSaveToolTipDefaultValue); + + //偏好菜单 + dictCurrentLanguageFields[nameof(Preferences)] = new Field(preferencesDefaultValue); + dictCurrentLanguageFields[nameof(PreferencesToolTip)] = new Field(preferencesToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ApplicationSettings)] = new Field(applicationSettingsDefaultValue); + dictCurrentLanguageFields[nameof(AutoUpdate)] = new Field(autoUpdateDefaultValue); + dictCurrentLanguageFields[nameof(AutoUpdateToolTip)] = new Field(autoUpdateToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ThemeIssue)] = new Field(themeIssueDefaultValue); + dictCurrentLanguageFields[nameof(ThemeIssueToolTip)] = new Field(themeIssueToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SaveClosedHistory)] = new Field(saveClosedHistoryDefaultValue); + dictCurrentLanguageFields[nameof(SaveClosedHistoryToolTip)] = new Field(saveClosedHistoryToolTipDefaultValue); + dictCurrentLanguageFields[nameof(RestorePreviousWindows)] = new Field(restorePreviousWindowsDefaultValue); + dictCurrentLanguageFields[nameof(RestorePreviousWindowsToolTip)] = new Field(restorePreviousWindowsToolTipDefaultValue); + dictCurrentLanguageFields[nameof(HideTrayIcon)] = new Field(hideTrayIconDefaultValue); + dictCurrentLanguageFields[nameof(HideTrayIconToolTip)] = new Field(hideTrayIconToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SelectLanguage)] = new Field(selectLanguageDefaultValue); + dictCurrentLanguageFields[nameof(SelectLanguageToolTip)] = new Field(selectLanguageToolTipDefaultValue); + + //关于菜单 + dictCurrentLanguageFields[nameof(About)] = new Field(aboutDefaultValue); + dictCurrentLanguageFields[nameof(AboutToolTip)] = new Field(aboutToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Profile)] = new Field(profileDefaultValue); + dictCurrentLanguageFields[nameof(Star)] = new Field(starDefaultValue); + dictCurrentLanguageFields[nameof(SupportProject)] = new Field(supportProjectDefaultValue); + dictCurrentLanguageFields[nameof(SupportProjectText)] = new Field(supportProjectTextDefaultValue); + dictCurrentLanguageFields[nameof(GitHubSponsors)] = new Field(gitHubSponsorsDefaultValue); + dictCurrentLanguageFields[nameof(Patreon)] = new Field(patreonDefaultValue); + dictCurrentLanguageFields[nameof(Coffee)] = new Field(coffeeDefaultValue); + dictCurrentLanguageFields[nameof(PayPal)] = new Field(payPalDefaultValue); + dictCurrentLanguageFields[nameof(Developer)] = new Field(developerDefaultValue); + dictCurrentLanguageFields[nameof(Supporters)] = new Field(supportersDefaultValue); + dictCurrentLanguageFields[nameof(SupportersText)] = new Field(supportersTextDefaultValue); + dictCurrentLanguageFields[nameof(FirstSupport)] = new Field(firstSupportDefaultValue); + dictCurrentLanguageFields[nameof(SupportMeaning)] = new Field(supportMeaningDefaultValue); + + //任务栏菜单 + dictCurrentLanguageFields[nameof(NotifyIconText)] = new Field(notifyIconTextDefaultValue); + dictCurrentLanguageFields[nameof(KeyboardHook)] = new Field(keyboardHookDefaultValue); + dictCurrentLanguageFields[nameof(KeyboardHookToolTip)] = new Field(keyboardHookToolTipDefaultValue); + dictCurrentLanguageFields[nameof(MouseHook)] = new Field(mouseHookDefaultValue); + dictCurrentLanguageFields[nameof(MouseHookToolTip)] = new Field(mouseHookToolTipDefaultValue); + dictCurrentLanguageFields[nameof(WindowHook)] = new Field(windowHookDefaultValue); + dictCurrentLanguageFields[nameof(WindowHookToolTip)] = new Field(windowHookToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ReuseTabs)] = new Field(reuseTabsDefaultValue); + dictCurrentLanguageFields[nameof(ReuseTabsToolTip)] = new Field(reuseTabsToolTipDefaultValue); + dictCurrentLanguageFields[nameof(AddToStartup)] = new Field(addToStartupDefaultValue); + dictCurrentLanguageFields[nameof(AddToStartupToolTip)] = new Field(addToStartupToolTipDefaultValue); + dictCurrentLanguageFields[nameof(CheckForUpdates)] = new Field(checkForUpdatesDefaultValue); + dictCurrentLanguageFields[nameof(CheckForUpdatesToolTip)] = new Field(checkForUpdatesToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Settings)] = new Field(settingsDefaultValue); + dictCurrentLanguageFields[nameof(SettingsToolTip)] = new Field(settingsToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Exit)] = new Field(exitDefaultValue); + dictCurrentLanguageFields[nameof(ExitToolTip)] = new Field(exitToolTipDefaultValue); + + //快捷键配置控件 + dictCurrentLanguageFields[nameof(EnabledToolTip)] = new Field(enabledToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Name)] = new Field(nameDefaultValue); + dictCurrentLanguageFields[nameof(NameToolTip)] = new Field(nameToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Hotkeys)] = new Field(hotkeysDefaultValue); + dictCurrentLanguageFields[nameof(HotkeysToolTip)] = new Field(hotkeysToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ScopeToolTip)] = new Field(scopeToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ActionToolTip)] = new Field(actionToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ExpanderToggleToolTip)] = new Field(expanderToggleToolTipDefaultValue); + dictCurrentLanguageFields[nameof(DeleteToolTip)] = new Field(deleteToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Path)] = new Field(pathDefaultValue); + dictCurrentLanguageFields[nameof(PathToolTip)] = new Field(pathToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Delay)] = new Field(delayDefaultValue); + dictCurrentLanguageFields[nameof(DelayToolTip)] = new Field(delayToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Handled)] = new Field(handledDefaultValue); + dictCurrentLanguageFields[nameof(HandledToolTip)] = new Field(handledToolTipDefaultValue); + dictCurrentLanguageFields[nameof(OpenAsTab)] = new Field(openAsTabDefaultValue); + dictCurrentLanguageFields[nameof(OpenAsTabToolTip)] = new Field(openAsTabToolTipDefaultValue); + + //自定义消息弹窗控件 + dictCurrentLanguageFields[nameof(Ok)] = new Field(okDefaultValue); + dictCurrentLanguageFields[nameof(Cancel)] = new Field(cancelDefaultValue); + dictCurrentLanguageFields[nameof(Yes)] = new Field(yesDefaultValue); + dictCurrentLanguageFields[nameof(No)] = new Field(noDefaultValue); + + //标签页搜索控件 + dictCurrentLanguageFields[nameof(ClearToolTip)] = new Field(clearToolTipDefaultValue); + + //消息 + dictCurrentLanguageFields[nameof(AlreadyRunning)] = new Field(alreadyRunningDefaultValue); + dictCurrentLanguageFields[nameof(RestorePreviouslyOpenedWindows)] = new Field(restorePreviouslyOpenedWindowsDefaultValue); + dictCurrentLanguageFields[nameof(HideTrayIconWithHotkeys)] = new Field(hideTrayIconWithHotkeysDefaultValue); + dictCurrentLanguageFields[nameof(HideTrayIconWithOutHotkeys)] = new Field(hideTrayIconWithOutHotkeysDefaultValue); + dictCurrentLanguageFields[nameof(ConfirmClearHistory)] = new Field(confirmClearHistoryDefaultValue); + dictCurrentLanguageFields[nameof(ConfirmClearHistoryTitle)] = new Field(confirmClearHistoryTitleDefaultValue); + + //HotkeyScope枚举 + dictCurrentLanguageFields[nameof(Global)] = new Field(globalDefaultValue); + dictCurrentLanguageFields[nameof(FileExplorer)] = new Field(fileExplorerDefaultValue); + + //HotKeyAction枚举 + dictCurrentLanguageFields[nameof(Open)] = new Field(openDefaultValue); + dictCurrentLanguageFields[nameof(OpenToolTip)] = new Field(openToolTipDefaultValue); + dictCurrentLanguageFields[nameof(Duplicate)] = new Field(duplicateDefaultValue); + dictCurrentLanguageFields[nameof(DuplicateToolTip)] = new Field(duplicateToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ReopenClosed)] = new Field(reopenClosedDefaultValue); + dictCurrentLanguageFields[nameof(ReopenClosedToolTip)] = new Field(reopenClosedToolTipDefaultValue); + dictCurrentLanguageFields[nameof(TabSearch)] = new Field(tabSearchDefaultValue); + dictCurrentLanguageFields[nameof(TabSearchToolTip)] = new Field(tabSearchToolTipDefaultValue); + dictCurrentLanguageFields[nameof(NavigateBack)] = new Field(navigateBackDefaultValue); + dictCurrentLanguageFields[nameof(NavigateBackToolTip)] = new Field(navigateBackToolTipDefaultValue); + dictCurrentLanguageFields[nameof(NavigateUp)] = new Field(navigateUpDefaultValue); + dictCurrentLanguageFields[nameof(NavigateUpToolTip)] = new Field(navigateUpToolTipDefaultValue); + dictCurrentLanguageFields[nameof(NavigateForward)] = new Field(navigateForwardDefaultValue); + dictCurrentLanguageFields[nameof(NavigateForwardToolTip)] = new Field(navigateForwardToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SetTargetWindow)] = new Field(setTargetWindowDefaultValue); + dictCurrentLanguageFields[nameof(SetTargetWindowToolTip)] = new Field(setTargetWindowToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ToggleWinHook)] = new Field(toggleWinHookDefaultValue); + dictCurrentLanguageFields[nameof(ToggleWinHookToolTip)] = new Field(toggleWinHookToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ToggleReuseTabs)] = new Field(toggleReuseTabsDefaultValue); + dictCurrentLanguageFields[nameof(ToggleReuseTabsToolTip)] = new Field(toggleReuseTabsToolTipDefaultValue); + dictCurrentLanguageFields[nameof(ToggleVisibility)] = new Field(toggleVisibilityDefaultValue); + dictCurrentLanguageFields[nameof(ToggleVisibilityToolTip)] = new Field(toggleVisibilityToolTipDefaultValue); + dictCurrentLanguageFields[nameof(DetachTab)] = new Field(detachTabDefaultValue); + dictCurrentLanguageFields[nameof(DetachTabToolTip)] = new Field(detachTabToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SnapRight)] = new Field(snapRightDefaultValue); + dictCurrentLanguageFields[nameof(SnapRightToolTip)] = new Field(snapRightToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SnapLeft)] = new Field(snapLeftDefaultValue); + dictCurrentLanguageFields[nameof(SnapLeftToolTip)] = new Field(snapLeftToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SnapUp)] = new Field(snapUpDefaultValue); + dictCurrentLanguageFields[nameof(SnapUpToolTip)] = new Field(snapUpToolTipDefaultValue); + dictCurrentLanguageFields[nameof(SnapDown)] = new Field(snapDownDefaultValue); + dictCurrentLanguageFields[nameof(SnapDownToolTip)] = new Field(snapDownToolTipDefaultValue); + } + + /// + /// 获取值 + /// + /// + /// + /// + public string GetValue(string key) + { + if (dictCurrentLanguageFields.TryGetValue(key, out var field)) + { + return field.Value ?? field.DefaultValue; + } + return string.Empty; + } + + /// + /// 设置值,返回值是否更改 + /// + /// + /// + /// + public bool SetValue(string key, string value) + { + if (string.IsNullOrWhiteSpace(value) == false && dictCurrentLanguageFields.TryGetValue(key, out var field) && field.Value != value) + { + field.Value = value; + return true; + } + return false; + } + +#pragma warning disable CS8604 // 引用类型参数可能为 null。 + private string Get([CallerMemberName] string? propertyName = null) => GetValue(propertyName); +#pragma warning restore CS8604 // 引用类型参数可能为 null。 + + private void Set(string value, [CallerMemberName] string? propertyName = null) + { + if (propertyName != null && SetValue(propertyName, value)) + { + RaisePropertyChanged(propertyName); + } + } + #endregion + + #region 通知所有属性已更改 + /// + /// 通知所有属性已更改 + /// + public void RaiseAllPropertyChanged() + { + foreach (var key in dictCurrentLanguageFields.Keys) + { + RaisePropertyChanged(key); + } + } + #endregion + } +} diff --git a/ExplorerTabUtility/Languages/en-US.txt b/ExplorerTabUtility/Languages/en-US.txt new file mode 100644 index 0000000..82db404 --- /dev/null +++ b/ExplorerTabUtility/Languages/en-US.txt @@ -0,0 +1,148 @@ +//Language Info +LanguageName:English + +//JsonFileFilter +JsonFiles:JSON files (*.json) +AllFiles :All Files + +//Shortcuts Menu +Shortcuts :Shortcuts +ShortcutsToolTip :Configure keyboard and mouse shortcuts +OpenApplicationMenu:Open application menu +New :NEW +NewToolTip :Create a new profile +Import :IMPORT +ImportToolTip :Import profiles from a file +Export :EXPORT +ExportToolTip :Export profiles to a file +Save :SAVE +SaveToolTip :Persist all profile changes +AutoSave :Auto save +AutoSaveToolTip :Automatically save profiles when closing the window + +//Preferences Menu +Preferences :Preferences +PreferencesToolTip :Configure application settings +ApplicationSettings :Application Settings +AutoUpdate :Auto update +AutoUpdateToolTip :Automatically check for updates on startup +ThemeIssue :I have theme issues +ThemeIssueToolTip :Use alternative window hiding method that preserves your custom File-Explorer theme. Enable this if you have theme-related issues +SaveClosedHistory :Save closed history +SaveClosedHistoryToolTip :Save closed windows history so you can reopen them later (ReopenClosed, Tab search) +RestorePreviousWindows :Restore previous windows +RestorePreviousWindowsToolTip:Restore previously opened windows after restart or crash +HideTrayIcon :Hide tray icon +HideTrayIconToolTip :Hide the system tray icon +SelectLanguage :Language +SelectLanguageToolTip :Select Language + +//About Menu +About :About +AboutToolTip :About the application and support options +Profile :Enhance your Windows File Explorer experience +Star :Star on GitHub +SupportProject :Support the Project +SupportProjectText:If you find this utility helpful, consider supporting its development through one of these options: +GitHubSponsors :GitHub Sponsors +Patreon :Patreon +Coffee :Buy Me A Coffee +PayPal :PayPal +Developer :Developer +Supporters :Current Supporters +SupportersText :Thank you to all the amazing people who support this project! +FirstSupport :Be the first to support this project! +SupportMeaning :Your support helps keep this project alive + +//Taskbar Menu +NotifyIconText :Explorer Tab Utility: Force new windows to tabs. +KeyboardHook :Keyboard Hook +KeyboardHookToolTip :Enable or disable keyboard shortcuts +MouseHook :Mouse Hook +MouseHookToolTip :Enable or disable mouse shortcuts +WindowHook :Window Hook +WindowHookToolTip :Toggle automatic redirection of new Explorer windows to tabs +ReuseTabs :Reuse Tabs +ReuseTabsToolTip :When enabled, navigates to existing tabs instead of opening duplicate tabs +AddToStartup :Add to startup +AddToStartupToolTip :Automatically start Explorer Tab Utility when Windows starts +CheckForUpdates :Check for updates +CheckForUpdatesToolTip:Check if a newer version of Explorer Tab Utility is available +Settings :Settings +SettingsToolTip :Open the settings window to configure the application +Exit :Exit +ExitToolTip :Close Explorer Tab Utility and stop all hooks + +//HotKeyProfileControl +EnabledToolTip :Enable or disable this profile +Name :Name +NameToolTip :Name of the profile +Hotkeys :Hotkeys +HotkeysToolTip :Keyboard or mouse keys to listen for. Click to record a new key combination. +ScopeToolTip :Scope of the hotkeys: Global (anywhere) or only when File Explorer is focused +ActionToolTip :Action to perform when the hotkeys are pressed +ExpanderToggleToolTip:Show more options +DeleteToolTip :Delete this profile +Path :Location +PathToolTip :Path to open when the hotkeys are pressed. (folder, file, website, CLSID) +Delay :Delay +DelayToolTip :Delay in milliseconds before performing the action +Handled :Handled +HandledToolTip :Prevent further processing of the hotkeys in other applications +OpenAsTab :Tab +OpenAsTabToolTip :Open as tab instead of a new window + +//CustomMessageBox +Ok :OK +Cancel:Cancel +Yes :Yes +No :No + +//TabSearchPopup +ClearToolTip:Clear closed windows history + +//Message +AlreadyRunning :Another instance is already running.\r\nCheck in System Tray Icons. +RestorePreviouslyOpenedWindows:Do you want to restore previously opened windows? +HideTrayIconWithHotkeys :You can show the app again by pressing {0} +HideTrayIconWithOutHotkeys :Cannot hide tray icon if no hotkey is configured to toggle visibility. +ConfirmClearHistory :Are you sure you want to clear the closed windows history? +ConfirmClearHistoryTitle :Confirm Clear History + +//HotkeyScope Enum +Global :Global +FileExplorer:FileExplorer + +//HotKeyAction Enum +Open :Open +OpenToolTip :Open a new tab/window with the specified location. +Duplicate :Duplicate +DuplicateToolTip :Duplicate the current tab. +ReopenClosed :ReopenClosed +ReopenClosedToolTip :Reopen the last closed location. +TabSearch :TabSearch +TabSearchToolTip :Open tab search popup to find and switch between tabs. +NavigateBack :NavigateBack +NavigateBackToolTip :Navigate back. +NavigateUp :NavigateUp +NavigateUpToolTip :Navigate up. +NavigateForward :NavigateForward +NavigateForwardToolTip :Navigate forward. +SetTargetWindow :SetTargetWindow +SetTargetWindowToolTip :Mark the window that will receive the new tabs. +ToggleWinHook :ToggleWinHook +ToggleWinHookToolTip :Toggle the window hook. +ToggleReuseTabs :ToggleReuseTabs +ToggleReuseTabsToolTip :Toggle the reuse tabs option. +ToggleVisibility :ToggleVisibility +ToggleVisibilityToolTip:Show/Hide the app. +DetachTab :DetachTab +DetachTabToolTip :Detach the current tab. +SnapRight :SnapRight +SnapRightToolTip :Snap the current window to the right. +SnapLeft :SnapLeft +SnapLeftToolTip :Snap the current window to the left. +SnapUp :SnapUp +SnapUpToolTip :Snap the current window to the top. +SnapDown :SnapDown +SnapDownToolTip :Snap the current window to the bottom. \ No newline at end of file diff --git a/ExplorerTabUtility/Languages/zh-CN.txt b/ExplorerTabUtility/Languages/zh-CN.txt new file mode 100644 index 0000000..0f3196b --- /dev/null +++ b/ExplorerTabUtility/Languages/zh-CN.txt @@ -0,0 +1,148 @@ +//语言信息 +LanguageName:简体中文 + +//文件筛选 +JsonFiles:Json文件(*.json) +AllFiles :所有文件(*.*) + +//快捷键菜单 +Shortcuts :快捷键 +ShortcutsToolTip :配置键盘和鼠标快捷键 +OpenApplicationMenu:打开程序菜单 +New :添加 +NewToolTip :添加新快捷键配置 +Import :导入 +ImportToolTip :导入快捷键配置 +Export :导出 +ExportToolTip :导出快捷键配置 +Save :保存 +SaveToolTip :保存所有配置 +AutoSave :自动保存 +AutoSaveToolTip :关闭窗口时自动保存配置 + +//偏好菜单 +Preferences :设置 +PreferencesToolTip :配置程序设置 +ApplicationSettings :程序设置 +AutoUpdate :自动更新 +AutoUpdateToolTip :启动时自动检查更新 +ThemeIssue :我有主题问题 +ThemeIssueToolTip :如果您遇到与主题相关的问题,请勾选此选项 +SaveClosedHistory :保存关闭历史 +SaveClosedHistoryToolTip :保存已关闭窗口的历史记录,以便稍后重新打开(重新打开已关闭的窗口、标签页搜索) +RestorePreviousWindows :恢复窗口 +RestorePreviousWindowsToolTip:重启或崩溃后恢复之前打开的窗口 +HideTrayIcon :隐藏托盘图标 +HideTrayIconToolTip :隐藏系统托盘图标 +SelectLanguage :语言 +SelectLanguageToolTip :选择语言 + +//关于菜单 +About :关于 +AboutToolTip :关于程序和支持选项 +Profile :提升您的Windows文件资源管理器使用体验 +Star :GitHub星标 +SupportProject :支持项目 +SupportProjectText:如果您觉得这个程序有用,可以考虑通过以下方式支持其开发: +GitHubSponsors :GitHub赞助 +Patreon :Patreon众筹 +Coffee :请我喝杯咖啡 +PayPal :PayPal付款 +Developer :开发者 +Supporters :支持者 +SupportersText :感谢所有支持这个项目的人! +FirstSupport :成为首位支持此项目的人! +SupportMeaning :您的支持有助于这个项目走的更远 + +//任务栏菜单 +NotifyIconText :资源管理器实用工具:强制将新窗口转换为标签页 +KeyboardHook :键盘钩子 +KeyboardHookToolTip :启用或禁用键盘快捷键 +MouseHook :鼠标钩子 +MouseHookToolTip :启用或禁用鼠标快捷键 +WindowHook :资源管理器钩子 +WindowHookToolTip :在标签页打开新资源管理器 +ReuseTabs :重用标签页 +ReuseTabsToolTip :启用后,将导航至现有标签页,而非打开重复的标签页 +AddToStartup :开机启动 +AddToStartupToolTip :开机时自动打开Explorer Tab Utility +CheckForUpdates :检查更新 +CheckForUpdatesToolTip:检查是否有可用的更新 +Settings :设置 +SettingsToolTip :打开设置窗口 +Exit :退出 +ExitToolTip :退出Explorer Tab Utility并停止所有的钩子 + +//快捷键配置控件 +EnabledToolTip :启用或禁用配置 +Name :名称 +NameToolTip :配置名称 +Hotkeys :快捷键 +HotkeysToolTip :要监听的键盘或鼠标按键。点击以录制新的按键组合 +ScopeToolTip :快捷键的作用范围:全局(任何地方)或仅当文件资源管理器处于焦点时 +ActionToolTip :按下快捷键时要执行的操作 +ExpanderToggleToolTip:显示更多配置 +DeleteToolTip :删除当前配置 +Path :路径 +PathToolTip :按下快捷键时打开的路径(文件夹、文件、网站、CLSID唯一标识符) +Delay :延迟 +DelayToolTip :执行操作前的延迟时间,单位毫秒 +Handled :已处理 +HandledToolTip :阻止在其他应用程序中处理此快捷键 +OpenAsTab :标签页 +OpenAsTabToolTip :以标签页形式打开,而非新窗口 + +//自定义消息弹窗控件 +Ok :确定 +Cancel:取消 +Yes :是 +No :否 + +//标签页搜索控件 +ClearToolTip:清除已关闭窗口的历史记录 + +//提示消息 +AlreadyRunning :另一个实例已在运行。\r\n请检查系统托盘图标。 +RestorePreviouslyOpenedWindows:您想恢复之前打开的窗口吗? +HideTrayIconWithHotkeys :您可以通过按下{0}来恢复显示。 +HideTrayIconWithOutHotkeys :如果未配置快捷键来切换显示,则无法隐藏托盘图标。 +ConfirmClearHistory :您确定要清除已关闭窗口的历史记录吗? +ConfirmClearHistoryTitle :确认清除历史记录 + +//HotkeyScope枚举 +Global :全局 +FileExplorer:资源管理器 + +//HotKeyAction枚举 +Open :打开 +OpenToolTip :在新标签页或者窗口打开指定的路径 +Duplicate :重复 +DuplicateToolTip :重复当前标签页 +ReopenClosed :重新打开 +ReopenClosedToolTip :重新打开上一个已关闭的路径 +TabSearch :标签页搜索 +TabSearchToolTip :打开标签页搜索框,以查找切换标签页 +NavigateBack :后退 +NavigateBackToolTip :导航后退 +NavigateUp :父目录 +NavigateUpToolTip :返回父目录 +NavigateForward :前进 +NavigateForwardToolTip :导航前进 +SetTargetWindow :标记窗口 +SetTargetWindowToolTip :标记接收新标签页的窗口 +ToggleWinHook :资源管理器开关 +ToggleWinHookToolTip :切换是否在标签页打开新资源管理器 +ToggleReuseTabs :重用标签页开关 +ToggleReuseTabsToolTip :切换是否重用标签页 +ToggleVisibility :程序显隐开关 +ToggleVisibilityToolTip:切换显示或隐藏程序 +DetachTab :分离标签 +DetachTabToolTip :分离当前标签页 +SnapRight :右贴靠 +SnapRightToolTip :将当前窗口贴靠到屏幕右侧 +SnapLeft :左贴靠 +SnapLeftToolTip :将当前窗口贴靠到屏幕左侧 +SnapUp :上贴靠 +SnapUpToolTip :将当前窗口贴靠到屏幕上侧 +SnapDown :底贴靠 +SnapDownToolTip :将当前窗口贴靠到屏幕底侧 \ No newline at end of file diff --git a/ExplorerTabUtility/Managers/ProfileManager.cs b/ExplorerTabUtility/Managers/ProfileManager.cs index 89865fe..4dc8c27 100644 --- a/ExplorerTabUtility/Managers/ProfileManager.cs +++ b/ExplorerTabUtility/Managers/ProfileManager.cs @@ -63,7 +63,10 @@ private void RemoveProfile(HotKeyProfile profile) _tempProfiles.Remove(profile); var control = FindControlByProfile(profile); if (control != null) + { _profilePanel.Children.Remove(control); + control.Dispose(); + } } private void RefreshPanel() diff --git a/ExplorerTabUtility/Managers/SettingsManager.cs b/ExplorerTabUtility/Managers/SettingsManager.cs index 0cac9aa..e5a0a50 100644 --- a/ExplorerTabUtility/Managers/SettingsManager.cs +++ b/ExplorerTabUtility/Managers/SettingsManager.cs @@ -190,6 +190,15 @@ public static WindowRecord[]? ClosedWindows } } + public static string? Language + { + get => Settings.Language; + set + { + Settings.Language = value; + SaveSettings(); + } + } public static void SaveSettings() { @@ -221,4 +230,5 @@ internal class AppSettings public bool SaveClosedWindows { get; set; } public bool RestorePreviousWindows { get; set; } public WindowRecord[]? ClosedWindows { get; set; } + public string? Language { get; set; } } \ No newline at end of file diff --git a/ExplorerTabUtility/Models/BindableBase.cs b/ExplorerTabUtility/Models/BindableBase.cs new file mode 100644 index 0000000..5723610 --- /dev/null +++ b/ExplorerTabUtility/Models/BindableBase.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace ExplorerTabUtility.Models +{ + internal abstract class BindableBase : INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + + protected virtual bool SetProperty(ref T storage, T value, [CallerMemberName] string? propertyName = null) + { + if (EqualityComparer.Default.Equals(storage, value)) + { + return false; + } + + storage = value; + RaisePropertyChanged(propertyName); + return true; + } + + protected virtual bool SetProperty(ref T storage, T value, Action onChanged, [CallerMemberName] string? propertyName = null) + { + if (EqualityComparer.Default.Equals(storage, value)) + { + return false; + } + + storage = value; + onChanged?.Invoke(); + RaisePropertyChanged(propertyName); + return true; + } + + protected void RaisePropertyChanged([CallerMemberName] string? propertyName = null) + { + OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); + } + + protected virtual void OnPropertyChanged(PropertyChangedEventArgs args) + { + PropertyChanged?.Invoke(this, args); + } + } +} diff --git a/ExplorerTabUtility/Models/ComboBoxItemInfo.cs b/ExplorerTabUtility/Models/ComboBoxItemInfo.cs new file mode 100644 index 0000000..eda2f0b --- /dev/null +++ b/ExplorerTabUtility/Models/ComboBoxItemInfo.cs @@ -0,0 +1,49 @@ +namespace ExplorerTabUtility.Models +{ + internal class ComboBoxItemInfo : BindableBase + { + private TKey key; + /// + /// 主键 + /// + public TKey Key + { + get { return key; } + set { SetProperty(ref key, value); } + } + + private string display; + /// + /// 显示值 + /// + public string Display + { + get { return display; } + set { SetProperty(ref display, value); } + } + + private string? toolTip; + /// + /// 提示 + /// + public string? ToolTip + { + get { return toolTip; } + set { SetProperty(ref toolTip, value); } + } + + public ComboBoxItemInfo(TKey key, string display, string? toolTip = null) + { + this.key = key; + this.display = display; + this.toolTip = toolTip; + } + } + + internal class ComboBoxItemInfo : ComboBoxItemInfo + { + public ComboBoxItemInfo(string key, string display, string? tooltip = null) : base(key, display, tooltip) + { + } + } +} diff --git a/ExplorerTabUtility/UI/Converters/ComboBoxItemInfoConverter.cs b/ExplorerTabUtility/UI/Converters/ComboBoxItemInfoConverter.cs new file mode 100644 index 0000000..bb73596 --- /dev/null +++ b/ExplorerTabUtility/UI/Converters/ComboBoxItemInfoConverter.cs @@ -0,0 +1,37 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using ExplorerTabUtility.Models; + +namespace ExplorerTabUtility.UI.Converters +{ + internal class ComboBoxItemInfoConverter : IValueConverter + { + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value == null) return DependencyProperty.UnsetValue; + + string? tooltip = null; + if (value is ComboBoxItemInfo actionInfo) + { + tooltip = actionInfo.ToolTip; + } + else if (value is ComboBoxItemInfo scopeInfo) + { + tooltip = scopeInfo.ToolTip; + } + else if (value is ComboBoxItemInfo info) + { + tooltip = info.ToolTip; + } + + return tooltip ?? DependencyProperty.UnsetValue; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return value; + } + } +} diff --git a/ExplorerTabUtility/UI/Converters/MenuIconTextConverter.cs b/ExplorerTabUtility/UI/Converters/MenuIconTextConverter.cs new file mode 100644 index 0000000..bc57371 --- /dev/null +++ b/ExplorerTabUtility/UI/Converters/MenuIconTextConverter.cs @@ -0,0 +1,19 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace ExplorerTabUtility.UI.Converters +{ + internal class MenuIconTextConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + return values?.Length == 2 ? $"{values[0]} {values[1]}" : ""; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/ExplorerTabUtility/UI/Themes/ComboBoxStyles.xaml b/ExplorerTabUtility/UI/Themes/ComboBoxStyles.xaml index ac2187f..12c6701 100644 --- a/ExplorerTabUtility/UI/Themes/ComboBoxStyles.xaml +++ b/ExplorerTabUtility/UI/Themes/ComboBoxStyles.xaml @@ -4,7 +4,7 @@ xmlns:behaviors="clr-namespace:ExplorerTabUtility.UI.Behaviors"> - + - + @@ -286,7 +326,7 @@ - + @@ -310,7 +350,7 @@ - + @@ -334,7 +374,7 @@ - + diff --git a/ExplorerTabUtility/UI/Views/MainWindow.xaml.cs b/ExplorerTabUtility/UI/Views/MainWindow.xaml.cs index fafeba6..2177799 100644 --- a/ExplorerTabUtility/UI/Views/MainWindow.xaml.cs +++ b/ExplorerTabUtility/UI/Views/MainWindow.xaml.cs @@ -9,6 +9,8 @@ using ExplorerTabUtility.Helpers; using ExplorerTabUtility.Models; using ExplorerTabUtility.UI.Views.Controls; +using ExplorerTabUtility.Languages.Manager; +using System.Windows.Controls; namespace ExplorerTabUtility.UI.Views; @@ -19,6 +21,7 @@ public partial class MainWindow : Window private readonly ProfileManager _profileManager; private readonly SystemTrayIcon _notifyIconManager; private nint _handle; + private string _fileFilter; public MainWindow() { @@ -31,7 +34,9 @@ public MainWindow() _profileManager = new ProfileManager(ProfilesPanel); _hookManager = new HookManager(_profileManager); _notifyIconManager = new SystemTrayIcon(_profileManager, _hookManager, ShowWindow); + _fileFilter = GetFileFilter(); + InitLanguageComboBox(); SetupEventHandlers(); StartHooks(); @@ -54,6 +59,12 @@ public MainWindow() } } + private void InitLanguageComboBox() + { + CbLanguage.ItemsSource = LangeuageHelper.Instance.Languages; + CbLanguage.SelectedItem = LangeuageHelper.Instance.CurrentLanguage; + } + private void SetupEventHandlers() { Application.Current.Exit += OnApplicationExit; @@ -75,6 +86,7 @@ private void SetupEventHandlers() CbThemeIssue.Unchecked += CbThemeIssue_CheckedChanged; CbHideTrayIcon.Checked += CbHideTrayIcon_CheckedChanged; CbHideTrayIcon.Unchecked += CbHideTrayIcon_CheckedChanged; + CbLanguage.SelectionChanged += CbLanguage_SelectionChanged; // Window events SizeChanged += MainWindow_SizeChanged; @@ -88,6 +100,19 @@ private void SetupEventHandlers() CloseButton.Click += CloseButton_Click; } + private void CbLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + LangeuageHelper.Instance.CurrentLanguage = (ComboBoxItemInfo)CbLanguage.SelectedItem; + _fileFilter = GetFileFilter(); + } + + private string GetFileFilter() + { + var jsonFiles = LangeuageHelper.Instance.LanguageFields.JsonFiles; + var allFiles = LangeuageHelper.Instance.LanguageFields.AllFiles; + return $"{jsonFiles}|*.json|{allFiles}|*.*"; + } + private void StartHooks() { if (SettingsManager.IsWindowHookActive) _hookManager.StartWindowHook(); @@ -128,7 +153,7 @@ private void BtnImport_Click(object? _, RoutedEventArgs __) var ofd = new OpenFileDialog { FileName = Constants.HotKeyProfilesFileName, - Filter = Constants.JsonFileFilter + Filter = _fileFilter }; if (ofd.ShowDialog() != true) return; @@ -143,7 +168,7 @@ private void BtnExport_Click(object? _, RoutedEventArgs __) var sfd = new SaveFileDialog { FileName = Constants.HotKeyProfilesFileName, - Filter = Constants.JsonFileFilter + Filter = _fileFilter }; if (sfd.ShowDialog() != true) return; @@ -201,8 +226,8 @@ private void UpdateTrayIconVisibility(bool showAlert) if (isChecked && showAlert && !SettingsManager.IsTrayIconHidden) { var message = canToggleVisibility - ? $"You can show the app again by pressing {profile!.HotKeys!.HotKeysToString(profile.IsDoubleClick)}" - : "Cannot hide tray icon if no hotkey is configured to toggle visibility."; + ? string.Format(LangeuageHelper.Instance.LanguageFields.HideTrayIconWithHotkeys, profile!.HotKeys!.HotKeysToString(profile.IsDoubleClick)) + : LangeuageHelper.Instance.LanguageFields.HideTrayIconWithOutHotkeys; CustomMessageBox.Show(this, message, Constants.AppName); } diff --git a/ExplorerTabUtility/UI/Views/TabSearchPopup.xaml b/ExplorerTabUtility/UI/Views/TabSearchPopup.xaml index 757ce3a..e7cc9b5 100644 --- a/ExplorerTabUtility/UI/Views/TabSearchPopup.xaml +++ b/ExplorerTabUtility/UI/Views/TabSearchPopup.xaml @@ -1,6 +1,7 @@ -