瀏覽代碼

Localized debug view model

Krzysztof Krysiński 2 年之前
父節點
當前提交
7ffa589bed

+ 29 - 0
src/PixiEditor/Data/Localization/Languages/en.json

@@ -23,9 +23,38 @@
   "CHECK_FOR_UPDATES": "Check updates on startup",
   "UPDATE_STREAM": "Update stream",
   "UPDATE_CHANNEL_HELP_TOOLTIP": "Update channels can only be changed in standalone version (downloaded from https://pixieditor.net).
Steam and Microsoft Store versions handle updates separately.",
+
   "DEBUG": "Debug",
   "ENABLE_DEBUG_MODE": "Enable Debug mode",
   "OPEN_CRASH_REPORTS_DIR": "Open crash reports directory",
+  "OPEN_TEMP_DIR": "Open temp directory",
+  "OPEN_LOCAL_APPDATA_DIR": "Open Local AppData directory",
+  "OPEN_ROAMING_APPDATA_DIR": "Open Roaming AppData directory",
+  "OPEN_INSTALLATION_DIR": "Open installation directory",
+  "DUMP_ALL_COMMANDS": "Dump all commands",
+  "DUMP_ALL_COMMANDS_DESCRIPTIVE": "Dump all commands to a text file",
+  "CRASH": "Crash",
+  "CRASH_APP": "Crash application",
+  "DELETE_USR_PREFS": "Delete user preferences (Roaming AppData)",
+  "DELETE_SHORTCUT_FILE": "Delete shortcut file (Roaming AppData)",
+  "DELETE_EDITOR_DATA": "Delete editor data (Local AppData)",
+
+  "GENERATE_KEY_BINDINGS_TEMPLATE": "Generate key bindings template",
+  "GENERATE_KEY_BINDINGS_TEMPLATE_DESCRIPTIVE": "Generate key bindings json template",
+  "VALIDATE_SHORTCUT_MAP": "Validate shortcut map",
+  "VALIDATE_SHORTCUT_MAP_DESCRIPTIVE": "Validates shortcut map",
+  "VALIDATION_KEYS_NOTICE_DIALOG": "Empty keys: {0}\nUnknown Commands: {1}",
+  "RESULT": "Result",
+  "CLEAR_RECENT_DOCUMENTS": "Clear recent documents",
+  "CLEAR_RECENTLY_OPENED_DOCUMENTS": "Clear recently opened documents",
+  "OPEN_CMD_DEBUG_WINDOW": "Open command debug window",
+
+  "PATH_DOES_NOT_EXIST": "{0} does not exist.",
+  "LOCATION_DOES_NOT_EXIST": "Location does not exist.",
+  "FILE_NOT_FOUND": "File not found.",
+  "FILE_NOT_FOUND_PATH_FULL_PATH": "File {0} does not exist\n(Full Path: {1})",
+  "ARE_YOU_SURE": "Are you sure?",
+  "ARE_YOU_SURE_PATH_FULL_PATH": "Are you sure you want to delete {0}?\nThis data will be lost for all installations.\n(Full Path: {1})",
   
   "DISCORD_RICH_PRESENCE": "Rich Presence",
   "ENABLED": "Enabled",

+ 3 - 2
src/PixiEditor/Models/Dialogs/NoticeDialog.cs

@@ -1,10 +1,11 @@
-using PixiEditor.Views.Dialogs;
+using PixiEditor.Localization;
+using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor.Models.Dialogs;
 
 internal static class NoticeDialog
 {
-    public static void Show(string message, string title)
+    public static void Show(LocalizedString message, LocalizedString title)
     {
         NoticePopup popup = new()
         {

+ 2 - 1
src/PixiEditor/Models/Dialogs/OptionsDialog.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Windows.Controls;
 using System.Windows.Media;
+using PixiEditor.Localization;
 using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor.Models.Dialogs;
@@ -15,7 +16,7 @@ internal class OptionsDialog<T> : CustomDialog, IEnumerable<T>
 
     public T Result { get; private set; }
 
-    public OptionsDialog(string title, object content)
+    public OptionsDialog(LocalizedString title, object content)
     {
         Title = title;
 

+ 19 - 18
src/PixiEditor/ViewModels/SubViewModels/Main/DebugViewModel.cs

@@ -5,6 +5,7 @@ using System.Windows.Input;
 using Microsoft.Win32;
 using Newtonsoft.Json;
 using PixiEditor.Helpers;
+using PixiEditor.Localization;
 using PixiEditor.Models.Commands.Attributes;
 using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Commands.Templates.Parsers;
@@ -36,23 +37,23 @@ internal class DebugViewModel : SubViewModel<ViewModelMain>
         UpdateDebugMode(preferences.GetPreference<bool>("IsDebugModeEnabled"));
     }
 
-    [Command.Debug("PixiEditor.Debug.OpenTempDirectory", @"%Temp%\PixiEditor", "Open Temp Directory", "Open Temp Directory", IconPath = "Folder.png")]
-    [Command.Debug("PixiEditor.Debug.OpenLocalAppDataDirectory", @"%LocalAppData%\PixiEditor", "Open Local AppData Directory", "Open Local AppData Directory", IconPath = "Folder.png")]
-    [Command.Debug("PixiEditor.Debug.OpenRoamingAppDataDirectory", @"%AppData%\PixiEditor", "Open Roaming AppData Directory", "Open Roaming AppData Directory", IconPath = "Folder.png")]
-    [Command.Debug("PixiEditor.Debug.OpenCrashReportsDirectory", @"%LocalAppData%\PixiEditor\crash_logs", "Open Crash Reports Directory", "Open Crash Reports Directory", IconPath = "Folder.png")]
+    [Command.Debug("PixiEditor.Debug.OpenTempDirectory", @"%Temp%\PixiEditor", "OPEN_TEMP_DIR", "OPEN_TEMP_DIR", IconPath = "Folder.png")]
+    [Command.Debug("PixiEditor.Debug.OpenLocalAppDataDirectory", @"%LocalAppData%\PixiEditor", "OPEN_LOCAL_APPDATA_DIR", "OPEN_LOCAL_APPDATA_DIR", IconPath = "Folder.png")]
+    [Command.Debug("PixiEditor.Debug.OpenRoamingAppDataDirectory", @"%AppData%\PixiEditor", "OPEN_ROAMING_APPDATA_DIR", "OPEN_ROAMING_APPDATA_DIR", IconPath = "Folder.png")]
+    [Command.Debug("PixiEditor.Debug.OpenCrashReportsDirectory", @"%LocalAppData%\PixiEditor\crash_logs", "OPEN_CRASH_REPORTS_DIR", "OPEN_CRASH_REPORTS_DIR", IconPath = "Folder.png")]
     public static void OpenFolder(string path)
     {
         string expandedPath = Environment.ExpandEnvironmentVariables(path);
         if (!Directory.Exists(expandedPath))
         {
-            NoticeDialog.Show($"{expandedPath} does not exist.", "Location does not exist");
+            NoticeDialog.Show(new LocalizedString("PATH_DOES_NOT_EXIST", expandedPath), "LOCATION_DOES_NOT_EXIST");
             return;
         }
 
         ProcessHelpers.ShellExecuteEV(path);
     }
     
-    [Command.Debug("PixiEditor.Debug.DumpAllCommands", "Dump All Commands", "Dump All Commands to a text file")]
+    [Command.Debug("PixiEditor.Debug.DumpAllCommands", "DUMP_ALL_COMMANDS", "DUMP_ALL_COMMANDS_DESCRIPTIVE")]
     public void DumpAllCommands()
     {
         SaveFileDialog dialog = new SaveFileDialog();
@@ -72,7 +73,7 @@ internal class DebugViewModel : SubViewModel<ViewModelMain>
         }
     }
     
-    [Command.Debug("PixiEditor.Debug.GenerateKeysTemplate", "Generate key bindings template", "Generates key bindings json template")]
+    [Command.Debug("PixiEditor.Debug.GenerateKeysTemplate", "GENERATE_KEY_BINDINGS_TEMPLATE", "GENERATE_KEY_BINDINGS_TEMPLATE_DESCRIPTIVE")]
     public void GenerateKeysTemplate()
     {
         SaveFileDialog dialog = new SaveFileDialog();
@@ -105,7 +106,7 @@ internal class DebugViewModel : SubViewModel<ViewModelMain>
         }
     }
 
-    [Command.Debug("PixiEditor.Debug.ValidateShortcutMap", "Validate Shortcut Map", "Validates shortcut map")]
+    [Command.Debug("PixiEditor.Debug.ValidateShortcutMap", "VALIDATE_SHORTCUT_MAP", "VALIDATE_SHORTCUT_MAP_DESCRIPTIVE")]
     public void ValidateShortcutMap()
     {
         OpenFileDialog dialog = new OpenFileDialog();
@@ -128,18 +129,18 @@ internal class DebugViewModel : SubViewModel<ViewModelMain>
                 }
             }
 
-            NoticeDialog.Show($"Empty keys: {emptyKeys}\nUnknown Commands: {unknownCommands}", "Result");
+            NoticeDialog.Show(new LocalizedString("VALIDATION_KEYS_NOTICE_DIALOG", emptyKeys, unknownCommands), "RESULT");
         }
     }
 
-    [Command.Debug("PixiEditor.Debug.ClearRecentDocument", "Clear recent documents", "Clear recently opened documents")]
+    [Command.Debug("PixiEditor.Debug.ClearRecentDocument", "CLEAR_RECENT_DOCUMENTS", "CLEAR_RECENTLY_OPENED_DOCUMENTS")]
     public void ClearRecentDocuments()
     {
         Owner.FileSubViewModel.RecentlyOpened.Clear();
         IPreferences.Current.UpdateLocalPreference(PreferencesConstants.RecentlyOpened, Array.Empty<object>());
     }
 
-    [Command.Debug("PixiEditor.Debug.OpenCommandDebugWindow", "Open command debug window", "Open command debug window")]
+    [Command.Debug("PixiEditor.Debug.OpenCommandDebugWindow", "OPEN_CMD_DEBUG_WINDOW", "OPEN_CMD_DEBUG_WINDOW")]
     public void OpenCommandDebugWindow()
     {
         Mouse.OverrideCursor = Cursors.Wait;
@@ -147,28 +148,28 @@ internal class DebugViewModel : SubViewModel<ViewModelMain>
         Mouse.OverrideCursor = null;
     }
 
-    [Command.Debug("PixiEditor.Debug.OpenInstallDirectory", "Open Installation Directory", "Open Installation Directory", IconPath = "Folder.png")]
+    [Command.Debug("PixiEditor.Debug.OpenInstallDirectory", "OPEN_INSTALLATION_DIR", "OPEN_INSTALLATION_DIR", IconPath = "Folder.png")]
     public static void OpenInstallLocation()
     {
         ProcessHelpers.ShellExecuteEV(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     }
 
-    [Command.Debug("PixiEditor.Debug.Crash", "Crash", "Crash Application")]
+    [Command.Debug("PixiEditor.Debug.Crash", "CRASH", "CRASH_APP")]
     public static void Crash() => throw new InvalidOperationException("User requested to crash :c");
 
-    [Command.Debug("PixiEditor.Debug.DeleteUserPreferences", @"%appdata%\PixiEditor\user_preferences.json", "Delete User Preferences (Roaming)", "Delete User Preferences (Roaming AppData)")]
-    [Command.Debug("PixiEditor.Debug.DeleteShortcutFile", @"%appdata%\PixiEditor\shortcuts.json", "Delete Shortcut File (Roaming)", "Delete Shortcut File (Roaming AppData)")]
-    [Command.Debug("PixiEditor.Debug.DeleteEditorData", @"%localappdata%\PixiEditor\editor_data.json", "Delete Editor Data (Local)", "Delete Editor Data (Local AppData)")]
+    [Command.Debug("PixiEditor.Debug.DeleteUserPreferences", @"%appdata%\PixiEditor\user_preferences.json", "DELETE_USR_PREFS", "DELETE_USR_PREFS")]
+    [Command.Debug("PixiEditor.Debug.DeleteShortcutFile", @"%appdata%\PixiEditor\shortcuts.json", "DELETE_SHORTCUT_FILE", "DELETE_SHORTCUT_FILE")]
+    [Command.Debug("PixiEditor.Debug.DeleteEditorData", @"%localappdata%\PixiEditor\editor_data.json", "DELETE_EDITOR_DATA", "DELETE_EDITOR_DATA")]
     public static void DeleteFile(string path)
     {
         string file = Environment.ExpandEnvironmentVariables(path);
         if (!File.Exists(file))
         {
-            NoticeDialog.Show($"File {path} does not exist\n(Full Path: {file})", "File not found");
+            NoticeDialog.Show(new LocalizedString("File {0} does not exist\n(Full Path: {1})", path, file), "FILE_NOT_FOUND");
             return;
         }
 
-        OptionsDialog<string> dialog = new("Are you sure?", $"Are you sure you want to delete {path}?\nThis data will be lost for all installations.\n(Full Path: {file})")
+        OptionsDialog<string> dialog = new("ARE_YOU_SURE", new LocalizedString("ARE_YOU_SURE_PATH_FULL_PATH", path, file))
         {
             { "Yes", x => File.Delete(file) },
             "Cancel"