From daaa4e1c3d8df15f25c753fea80de67c0a3cbbcf Mon Sep 17 00:00:00 2001 From: Supheria Date: Thu, 12 Dec 2024 13:09:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?loc:=20=E6=B7=BB=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Moder.Core/Models/SystemFileItem.cs | 27 ++--- .../WindowsFileNativeService.cs | 5 +- .../Menus/AppInitializeControlViewModel.cs | 6 +- Moder.Language/Strings/Resource.Designer.cs | 108 ++++++++++++++++++ Moder.Language/Strings/Resource.en-US.resx | 42 +++++++ Moder.Language/Strings/Resource.resx | 36 ++++++ 6 files changed, 204 insertions(+), 20 deletions(-) diff --git a/Moder.Core/Models/SystemFileItem.cs b/Moder.Core/Models/SystemFileItem.cs index 237c687..897d9b4 100644 --- a/Moder.Core/Models/SystemFileItem.cs +++ b/Moder.Core/Models/SystemFileItem.cs @@ -95,7 +95,7 @@ private async Task RenameAsync() { Title = Resource.Common_Rename, PrimaryButtonText = Resource.Common_Ok, - CloseButtonText = Resource.Common_Cancel + CloseButtonText = Resource.Common_Cancel, }; var view = new RenameFileControlView(dialog, this); @@ -104,7 +104,7 @@ private async Task RenameAsync() var result = await dialog.ShowAsync(); if (result != ContentDialogResult.Primary) { - Log.Debug("取消重命名"); + Log.Debug(Resource.RenameFile_CancelRename); return; } @@ -116,14 +116,14 @@ private async Task RenameAsync() var parentDir = Path.GetDirectoryName(FullPath); if (parentDir is null) { - Log.Warn("重命名文件失败,无法获取路径:{FullPath}", FullPath); + Log.Warn($"{Resource.RenameFile_CannotAquirePath}{FullPath}"); return; } var newPath = Path.Combine(parentDir, view.NewName); if (Path.Exists(newPath)) { - Log.Warn("重命名失败,目标文件或文件夹已存在:{FullPath}", FullPath); + Log.Warn($"{Resource.RenameFile_TargetAlreadyExists}{FullPath}"); return; } @@ -133,8 +133,8 @@ private async Task RenameAsync() } catch (Exception e) { - Log.Error(e, "重命名文件或文件夹时发生错误"); - await MessageBoxService.ErrorAsync("重命名文件或文件夹时发生错误"); + Log.Error(e, Resource.RenameFile_ErrorOccurs); + await MessageBoxService.ErrorAsync(Resource.RenameFile_ErrorOccurs); } } @@ -153,8 +153,10 @@ private void Rename(string newPath) [RelayCommand] private async Task DeleteFile() { - var text = IsFile ? $"确认删除 '{Name}' 吗?" : $"确认删除 '{Name}' 及其内容吗?"; - text += "\n\n您可以从回收站还原此文件"; + var text = IsFile + ? string.Format(Resource.DeleteFile_EnsureFile, Name) + : string.Format(Resource.DeleteFile_EnsureFolder, Name); + text += $"\n\n{Resource.DeleteFile_CanFindBack}"; var dialog = MessageBoxManager.GetMessageBoxStandard(Resource.Common_Delete, text, ButtonEnum.YesNo); var result = await dialog.ShowAsync(); @@ -166,13 +168,8 @@ private async Task DeleteFile() } else { - await MessageBoxService.ErrorAsync($"删除失败, 原因: {errorMessage}"); - Log.Warn( - "删除文件或文件夹失败:{FullPath}, 错误信息: {ErrorMessage} 错误代码: {Code}", - FullPath, - errorMessage, - errorCode - ); + await MessageBoxService.ErrorAsync($"{Resource.DeleteFile_Failed}{errorMessage}"); + Log.Warn(string.Format(Resource.DeleteFile_FailedLog, FullPath, errorMessage, errorCode)); } } } diff --git a/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs b/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs index afd5f21..533bef6 100644 --- a/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs +++ b/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; +using Moder.Language.Strings; using NLog; using Vanara.PInvoke; using Vanara.Windows.Shell; @@ -25,7 +26,7 @@ out int errorCode if (!Path.Exists(fileOrDirectoryPath)) { - errorMessage = "文件或文件夹不存在"; + errorMessage = Resource.FileManager_NotExist; errorCode = 0; return false; } @@ -69,7 +70,7 @@ public bool TryShowInExplorer( } catch (Exception e) { - Log.Error(e, "在文件资源管理器中打开失败, path:{Path}", fileOrDirectoryPath); + Log.Error(e, $"{Resource.FileManager_OpenFailed}{fileOrDirectoryPath}"); errorMessage = e.Message; return false; } diff --git a/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs b/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs index a8e1240..1a2ee0d 100644 --- a/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs +++ b/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs @@ -37,7 +37,7 @@ MessageBoxService messageBox [RelayCommand] private async Task SelectGameRootFolder() { - var gameRootPath = await SelectFolderInteraction.HandleAsync("选择游戏根目录"); + var gameRootPath = await SelectFolderInteraction.HandleAsync(Resource.InitializePage_SelectGameRootPath); if (string.IsNullOrEmpty(gameRootPath)) { return; @@ -49,7 +49,7 @@ private async Task SelectGameRootFolder() [RelayCommand] private async Task SelectModRootFolder() { - var modRootPath = await SelectFolderInteraction.HandleAsync("选择Mod根目录"); + var modRootPath = await SelectFolderInteraction.HandleAsync(Resource.InitializePage_SelectModRootPath); if (string.IsNullOrEmpty(modRootPath)) { return; @@ -70,7 +70,7 @@ private async Task Submit() settingService.GameRootFolderPath = GameRootFolderPath; settingService.ModRootFolderPath = ModRootFolderPath; - Log.Info("资源目录设置成功"); + Log.Info(Resource.InitializePage_SetResourceDirectorySuccess); WeakReferenceMessenger.Default.Send(new CompleteAppInitializeMessage()); } diff --git a/Moder.Language/Strings/Resource.Designer.cs b/Moder.Language/Strings/Resource.Designer.cs index 0fb2c4e..c13e5d1 100644 --- a/Moder.Language/Strings/Resource.Designer.cs +++ b/Moder.Language/Strings/Resource.Designer.cs @@ -374,6 +374,69 @@ public static string Common_WriteToFile { } } + /// + /// Looks up a localized string similar to 您可以从回收站还原此文件. + /// + public static string DeleteFile_CanFindBack { + get { + return ResourceManager.GetString("DeleteFile_CanFindBack", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 确认删除 '{0}' 吗?. + /// + public static string DeleteFile_EnsureFile { + get { + return ResourceManager.GetString("DeleteFile_EnsureFile", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 确认删除 '{0}' 及其内容吗?. + /// + public static string DeleteFile_EnsureFolder { + get { + return ResourceManager.GetString("DeleteFile_EnsureFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 删除失败,原因:. + /// + public static string DeleteFile_Failed { + get { + return ResourceManager.GetString("DeleteFile.Failed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 删除文件或文件夹失败:{0}, 错误信息: {1} 错误代码: {2}. + /// + public static string DeleteFile_FailedLog { + get { + return ResourceManager.GetString("DeleteFile_FailedLog", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 文件或文件夹不存在. + /// + public static string FileManager_NotExist { + get { + return ResourceManager.GetString("FileManager.NotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 在文件资源管理器中打开失败:{0}. + /// + public static string FileManager_OpenFailed { + get { + return ResourceManager.GetString("FileManager.OpenFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to 选择游戏根目录. /// @@ -392,6 +455,15 @@ public static string InitializePage_SelectModRootPath { } } + /// + /// Looks up a localized string similar to 资源目录设置成功. + /// + public static string InitializePage_SetResourceDirectorySuccess { + get { + return ResourceManager.GetString("InitializePage.SetResourceDirectorySuccess", resourceCulture); + } + } + /// /// Looks up a localized string similar to 未找到本地化的值. /// @@ -455,6 +527,33 @@ public static string NotSupportFileTipInfo { } } + /// + /// Looks up a localized string similar to 取消重命名. + /// + public static string RenameFile_CancelRename { + get { + return ResourceManager.GetString("RenameFile.CancelRename", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 重命名失败,无法获取路径:. + /// + public static string RenameFile_CannotAquirePath { + get { + return ResourceManager.GetString("RenameFile.CannotAquirePath", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 重命名文件或文件夹时发生错误. + /// + public static string RenameFile_ErrorOccurs { + get { + return ResourceManager.GetString("RenameFile_ErrorOccurs", resourceCulture); + } + } + /// /// Looks up a localized string similar to 无效的文件或文件夹名称. /// @@ -482,6 +581,15 @@ public static string RenameFile_NameContainInvalidChar { } } + /// + /// Looks up a localized string similar to 重命名失败,目标文件或文件夹已存在:. + /// + public static string RenameFile_TargetAlreadyExists { + get { + return ResourceManager.GetString("RenameFile.TargetAlreadyExists", resourceCulture); + } + } + /// /// Looks up a localized string similar to App 语言. /// diff --git a/Moder.Language/Strings/Resource.en-US.resx b/Moder.Language/Strings/Resource.en-US.resx index e824dc0..3fd8d7f 100644 --- a/Moder.Language/Strings/Resource.en-US.resx +++ b/Moder.Language/Strings/Resource.en-US.resx @@ -286,5 +286,47 @@ Complete + + + Select Game Root Path + + + Select Mod Root Path + + + Cencel Rename + + + Rename failed, cannot aquire path: + + + Rename failed, target file or folder already exists: + + + An error occurs within file or folder renaming + + + Are you sure to delete '{0}'? + + + Are you sure to delete '{0}' and all of its content? + + + You can restore from recycle bin + + + Delete failed because: + + + Delete file or folder failed: {0}. Error message: {1}. Error code: {2} + + + File or folder doesn't exist + + + Open failed in the file manager: {0} + + + Resource directory sets successful \ No newline at end of file diff --git a/Moder.Language/Strings/Resource.resx b/Moder.Language/Strings/Resource.resx index 086feec..b6d9f9a 100644 --- a/Moder.Language/Strings/Resource.resx +++ b/Moder.Language/Strings/Resource.resx @@ -293,4 +293,40 @@ 完成 + + 取消重命名 + + + 重命名失败,无法获取路径: + + + 重命名失败,目标文件或文件夹已存在: + + + 重命名文件或文件夹时发生错误 + + + 确认删除 '{0}' 吗? + + + 确认删除 '{0}' 及其内容吗? + + + 您可以从回收站还原此文件 + + + 删除失败,原因: + + + 删除文件或文件夹失败:{0}, 错误信息: {1} 错误代码: {2} + + + 文件或文件夹不存在 + + + 在文件资源管理器中打开失败:{0} + + + 资源目录设置成功 + \ No newline at end of file From ffbde7b653a004003c9a0381407dfd177e53269c Mon Sep 17 00:00:00 2001 From: Supheria Date: Thu, 12 Dec 2024 23:52:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?loc:=20=E5=8E=BB=E9=99=A4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Moder.Core/Models/SystemFileItem.cs | 15 ++++--- .../WindowsFileNativeService.cs | 2 +- .../Menus/AppInitializeControlViewModel.cs | 2 +- Moder.Language/Strings/Resource.Designer.cs | 45 ------------------- Moder.Language/Strings/Resource.en-US.resx | 27 +++-------- Moder.Language/Strings/Resource.resx | 19 +------- 6 files changed, 20 insertions(+), 90 deletions(-) diff --git a/Moder.Core/Models/SystemFileItem.cs b/Moder.Core/Models/SystemFileItem.cs index 897d9b4..4b14877 100644 --- a/Moder.Core/Models/SystemFileItem.cs +++ b/Moder.Core/Models/SystemFileItem.cs @@ -104,7 +104,7 @@ private async Task RenameAsync() var result = await dialog.ShowAsync(); if (result != ContentDialogResult.Primary) { - Log.Debug(Resource.RenameFile_CancelRename); + Log.Debug("取消重命名"); return; } @@ -116,14 +116,14 @@ private async Task RenameAsync() var parentDir = Path.GetDirectoryName(FullPath); if (parentDir is null) { - Log.Warn($"{Resource.RenameFile_CannotAquirePath}{FullPath}"); + Log.Warn("重命名文件失败,无法获取路径:{FullPath}", FullPath); return; } var newPath = Path.Combine(parentDir, view.NewName); if (Path.Exists(newPath)) { - Log.Warn($"{Resource.RenameFile_TargetAlreadyExists}{FullPath}"); + Log.Warn("重命名失败,目标文件或文件夹已存在:{FullPath}", FullPath); return; } @@ -133,7 +133,7 @@ private async Task RenameAsync() } catch (Exception e) { - Log.Error(e, Resource.RenameFile_ErrorOccurs); + Log.Error(e, "重命名文件或文件夹时发生错误"); await MessageBoxService.ErrorAsync(Resource.RenameFile_ErrorOccurs); } } @@ -169,7 +169,12 @@ private async Task DeleteFile() else { await MessageBoxService.ErrorAsync($"{Resource.DeleteFile_Failed}{errorMessage}"); - Log.Warn(string.Format(Resource.DeleteFile_FailedLog, FullPath, errorMessage, errorCode)); + Log.Warn( + "删除文件或文件夹失败:{FullPath}, 错误信息: {ErrorMessage} 错误代码: {Code}", + FullPath, + errorMessage, + errorCode + ); } } } diff --git a/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs b/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs index 533bef6..69fc744 100644 --- a/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs +++ b/Moder.Core/Services/FileNativeService/WindowsFileNativeService.cs @@ -70,7 +70,7 @@ public bool TryShowInExplorer( } catch (Exception e) { - Log.Error(e, $"{Resource.FileManager_OpenFailed}{fileOrDirectoryPath}"); + Log.Error(e, "在文件资源管理器中打开失败, path:{Path}", fileOrDirectoryPath); errorMessage = e.Message; return false; } diff --git a/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs b/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs index 1a2ee0d..8929e52 100644 --- a/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs +++ b/Moder.Core/ViewsModel/Menus/AppInitializeControlViewModel.cs @@ -70,7 +70,7 @@ private async Task Submit() settingService.GameRootFolderPath = GameRootFolderPath; settingService.ModRootFolderPath = ModRootFolderPath; - Log.Info(Resource.InitializePage_SetResourceDirectorySuccess); + Log.Info("资源目录设置成功"); WeakReferenceMessenger.Default.Send(new CompleteAppInitializeMessage()); } diff --git a/Moder.Language/Strings/Resource.Designer.cs b/Moder.Language/Strings/Resource.Designer.cs index c13e5d1..9248f3f 100644 --- a/Moder.Language/Strings/Resource.Designer.cs +++ b/Moder.Language/Strings/Resource.Designer.cs @@ -410,15 +410,6 @@ public static string DeleteFile_Failed { } } - /// - /// Looks up a localized string similar to 删除文件或文件夹失败:{0}, 错误信息: {1} 错误代码: {2}. - /// - public static string DeleteFile_FailedLog { - get { - return ResourceManager.GetString("DeleteFile_FailedLog", resourceCulture); - } - } - /// /// Looks up a localized string similar to 文件或文件夹不存在. /// @@ -428,15 +419,6 @@ public static string FileManager_NotExist { } } - /// - /// Looks up a localized string similar to 在文件资源管理器中打开失败:{0}. - /// - public static string FileManager_OpenFailed { - get { - return ResourceManager.GetString("FileManager.OpenFailed", resourceCulture); - } - } - /// /// Looks up a localized string similar to 选择游戏根目录. /// @@ -455,15 +437,6 @@ public static string InitializePage_SelectModRootPath { } } - /// - /// Looks up a localized string similar to 资源目录设置成功. - /// - public static string InitializePage_SetResourceDirectorySuccess { - get { - return ResourceManager.GetString("InitializePage.SetResourceDirectorySuccess", resourceCulture); - } - } - /// /// Looks up a localized string similar to 未找到本地化的值. /// @@ -527,15 +500,6 @@ public static string NotSupportFileTipInfo { } } - /// - /// Looks up a localized string similar to 取消重命名. - /// - public static string RenameFile_CancelRename { - get { - return ResourceManager.GetString("RenameFile.CancelRename", resourceCulture); - } - } - /// /// Looks up a localized string similar to 重命名失败,无法获取路径:. /// @@ -581,15 +545,6 @@ public static string RenameFile_NameContainInvalidChar { } } - /// - /// Looks up a localized string similar to 重命名失败,目标文件或文件夹已存在:. - /// - public static string RenameFile_TargetAlreadyExists { - get { - return ResourceManager.GetString("RenameFile.TargetAlreadyExists", resourceCulture); - } - } - /// /// Looks up a localized string similar to App 语言. /// diff --git a/Moder.Language/Strings/Resource.en-US.resx b/Moder.Language/Strings/Resource.en-US.resx index 3fd8d7f..59dab30 100644 --- a/Moder.Language/Strings/Resource.en-US.resx +++ b/Moder.Language/Strings/Resource.en-US.resx @@ -248,9 +248,6 @@ The file or folder name contains invalid characters - - A file or folder with the same name already exists at this location: {0}. Please rename it - No modifier effect @@ -293,16 +290,10 @@ Select Mod Root Path - - Cencel Rename - - + Rename failed, cannot aquire path: - - Rename failed, target file or folder already exists: - - + An error occurs within file or folder renaming @@ -317,16 +308,10 @@ Delete failed because: - - Delete file or folder failed: {0}. Error message: {1}. Error code: {2} - - + File or folder doesn't exist - - Open failed in the file manager: {0} - - - Resource directory sets successful - + + A file or folder with the same name already exists at this location: {0}. Please rename it + \ No newline at end of file diff --git a/Moder.Language/Strings/Resource.resx b/Moder.Language/Strings/Resource.resx index b6d9f9a..f383062 100644 --- a/Moder.Language/Strings/Resource.resx +++ b/Moder.Language/Strings/Resource.resx @@ -248,9 +248,6 @@ 文件或文件夹名称包含非法字符 - - 此位置已存在同名文件或文件夹 {0}, 请重新命名 - 无修正效果 @@ -293,15 +290,9 @@ 完成 - - 取消重命名 - 重命名失败,无法获取路径: - - 重命名失败,目标文件或文件夹已存在: - 重命名文件或文件夹时发生错误 @@ -317,16 +308,10 @@ 删除失败,原因: - - 删除文件或文件夹失败:{0}, 错误信息: {1} 错误代码: {2} - 文件或文件夹不存在 - - 在文件资源管理器中打开失败:{0} - - - 资源目录设置成功 + + 此位置已存在同名文件或文件夹 {0}, 请重新命名 \ No newline at end of file