From d00211c56841c7fc6224e956f0a38930465458c3 Mon Sep 17 00:00:00 2001 From: ashutosh nigam Date: Sun, 2 Mar 2025 15:49:32 +0530 Subject: [PATCH 1/2] Update localization to use centralized Strings class Refactor localization strings in archive compression and decompression actions to utilize a new `Strings` class. This change replaces direct string literals with references to the centralized resource management, enhancing maintainability and consistency across the application. Affected classes include `CompressIntoArchiveAction`, `CompressIntoSevenZipAction`, `CompressIntoZipAction`, `DecompressArchive`, `DecompressArchiveHere`, `DecompressArchiveHereSmart`, and `DecompressArchiveToChildFolderAction`. The `ComputeLabel` method in `DecompressArchiveToChildFolderAction` has also been updated for consistent localization. --- .../Archives/Compress/CompressIntoArchiveAction.cs | 4 ++-- .../Archives/Compress/CompressIntoSevenZipAction.cs | 4 ++-- .../Content/Archives/Compress/CompressIntoZipAction.cs | 4 ++-- .../Content/Archives/Decompress/DecompressArchive.cs | 4 ++-- .../Content/Archives/Decompress/DecompressArchiveHere.cs | 4 ++-- .../Archives/Decompress/DecompressArchiveHereSmart.cs | 4 ++-- .../Decompress/DecompressArchiveToChildFolderAction.cs | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs index 2fd4e5b3c9f5..f70809b032c8 100644 --- a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoArchiveAction.cs @@ -10,10 +10,10 @@ namespace Files.App.Actions internal sealed partial class CompressIntoArchiveAction : BaseCompressArchiveAction { public override string Label - => "CreateArchive".GetLocalizedResource(); + => Strings.CreateArchive.GetLocalizedResource(); public override string Description - => "CompressIntoArchiveDescription".GetLocalizedResource(); + => Strings.CompressIntoArchiveDescription.GetLocalizedResource(); public CompressIntoArchiveAction() { diff --git a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs index 000f30461a59..5f91093b7937 100644 --- a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs +++ b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoSevenZipAction.cs @@ -6,10 +6,10 @@ namespace Files.App.Actions internal sealed partial class CompressIntoSevenZipAction : BaseCompressArchiveAction { public override string Label - => string.Format("CreateNamedArchive".GetLocalizedResource(), $"{StorageArchiveService.GenerateArchiveNameFromItems(context.SelectedItems)}.7z"); + => string.Format(Strings.CreateNamedArchive.GetLocalizedResource(), $"{StorageArchiveService.GenerateArchiveNameFromItems(context.SelectedItems)}.7z"); public override string Description - => "CompressIntoSevenZipDescription".GetLocalizedResource(); + => Strings.CompressIntoSevenZipDescription.GetLocalizedResource(); public CompressIntoSevenZipAction() { diff --git a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs index c8d7d11c91e9..7742db5891e0 100644 --- a/src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs +++ b/src/Files.App/Actions/Content/Archives/Compress/CompressIntoZipAction.cs @@ -6,10 +6,10 @@ namespace Files.App.Actions internal sealed partial class CompressIntoZipAction : BaseCompressArchiveAction { public override string Label - => string.Format("CreateNamedArchive".GetLocalizedResource(), $"{StorageArchiveService.GenerateArchiveNameFromItems(context.SelectedItems)}.zip"); + => string.Format(Strings.CreateNamedArchive.GetLocalizedResource(), $"{StorageArchiveService.GenerateArchiveNameFromItems(context.SelectedItems)}.zip"); public override string Description - => "CompressIntoZipDescription".GetLocalizedResource(); + => Strings.CompressIntoZipDescription.GetLocalizedResource(); public CompressIntoZipAction() { diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs index 37206ce95d08..07aaf09dcce4 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs @@ -14,10 +14,10 @@ namespace Files.App.Actions internal sealed partial class DecompressArchive : BaseDecompressArchiveAction { public override string Label - => "ExtractFiles".GetLocalizedResource(); + => Strings.ExtractFiles.GetLocalizedResource(); public override string Description - => "DecompressArchiveDescription".GetLocalizedResource(); + => Strings.DecompressArchiveDescription.GetLocalizedResource(); public override HotKey HotKey => new(Keys.E, KeyModifiers.Ctrl); diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHere.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHere.cs index b79a236d9c8b..1e2568c787d8 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHere.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHere.cs @@ -6,10 +6,10 @@ namespace Files.App.Actions internal sealed partial class DecompressArchiveHere : BaseDecompressArchiveAction { public override string Label - => "ExtractHere".GetLocalizedResource(); + => Strings.ExtractHere.GetLocalizedResource(); public override string Description - => "DecompressArchiveHereDescription".GetLocalizedResource(); + => Strings.DecompressArchiveHereDescription.GetLocalizedResource(); public DecompressArchiveHere() { diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHereSmart.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHereSmart.cs index a7e29a0c881f..fb555fb9062e 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHereSmart.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveHereSmart.cs @@ -6,10 +6,10 @@ namespace Files.App.Actions internal sealed partial class DecompressArchiveHereSmart : BaseDecompressArchiveAction { public override string Label - => "ExtractHereSmart".GetLocalizedResource(); + => Strings.ExtractHereSmart.GetLocalizedResource(); public override string Description - => "DecompressArchiveHereSmartDescription".GetLocalizedResource(); + => Strings.DecompressArchiveHereSmartDescription.GetLocalizedResource(); public override HotKey HotKey => new(Keys.E, KeyModifiers.CtrlShift); diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs index d63bfaca0816..91dd6b41390a 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchiveToChildFolderAction.cs @@ -15,7 +15,7 @@ public override string Label => ComputeLabel(); public override string Description - => "DecompressArchiveToChildFolderDescription".GetLocalizedResource(); + => Strings.DecompressArchiveToChildFolderDescription.GetLocalizedResource(); public DecompressArchiveToChildFolderAction() { @@ -86,11 +86,11 @@ protected override void Context_PropertyChanged(object? sender, PropertyChangedE private string ComputeLabel() { if (context.SelectedItems == null || context.SelectedItems.Count == 0) - return string.Format("BaseLayoutItemContextFlyoutExtractToChildFolder".GetLocalizedResource(), string.Empty); + return string.Format(Strings.BaseLayoutItemContextFlyoutExtractToChildFolder.GetLocalizedResource(), string.Empty); return context.SelectedItems.Count > 1 - ? string.Format("BaseLayoutItemContextFlyoutExtractToChildFolder".GetLocalizedResource(), "*") - : string.Format("BaseLayoutItemContextFlyoutExtractToChildFolder".GetLocalizedResource(), SystemIO.Path.GetFileNameWithoutExtension(context.SelectedItems.First().Name)); + ? string.Format(Strings.BaseLayoutItemContextFlyoutExtractToChildFolder.GetLocalizedResource(), "*") + : string.Format(Strings.BaseLayoutItemContextFlyoutExtractToChildFolder.GetLocalizedResource(), SystemIO.Path.GetFileNameWithoutExtension(context.SelectedItems.First().Name)); } } } From 3e98ea4218438975862267b6b8e3954299ec7cf1 Mon Sep 17 00:00:00 2001 From: ashutosh nigam Date: Sun, 2 Mar 2025 16:35:53 +0530 Subject: [PATCH 2/2] Update localization for action classes in Files.App Refactor various action classes in the `Files.App.Actions` namespace to replace hardcoded string literals with references to a centralized `Strings` class for localization. This change applies to error messages, labels, and descriptions in `SetAsAppBackgroundAction`, `SetAsLockscreenBackgroundAction`, `SetAsSlideshowBackgroundAction`, `SetAsWallpaperBackgroundAction`, `RotateLeftAction`, and `RotateRightAction`, improving maintainability and localization support. --- src/Files.App/Actions/Content/Background/BaseSetAsAction.cs | 4 ++-- .../Actions/Content/Background/SetAsAppBackgroundAction.cs | 4 ++-- .../Content/Background/SetAsLockscreenBackgroundAction.cs | 4 ++-- .../Content/Background/SetAsSlideshowBackgroundAction.cs | 4 ++-- .../Content/Background/SetAsWallpaperBackgroundAction.cs | 4 ++-- .../Actions/Content/ImageManipulation/RotateLeftAction.cs | 4 ++-- .../Actions/Content/ImageManipulation/RotateRightAction.cs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs index ee134e2e7551..4a6af4f113dd 100644 --- a/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs +++ b/src/Files.App/Actions/Content/Background/BaseSetAsAction.cs @@ -34,9 +34,9 @@ protected async void ShowErrorDialog(string message) { var errorDialog = new ContentDialog() { - Title = "FailedToSetBackground".GetLocalizedResource(), + Title = Strings.FailedToSetBackground.GetLocalizedResource(), Content = message, - PrimaryButtonText = "OK".GetLocalizedResource(), + PrimaryButtonText = Strings.OK.GetLocalizedResource(), }; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) diff --git a/src/Files.App/Actions/Content/Background/SetAsAppBackgroundAction.cs b/src/Files.App/Actions/Content/Background/SetAsAppBackgroundAction.cs index b99cb68195e6..775f405fb3ce 100644 --- a/src/Files.App/Actions/Content/Background/SetAsAppBackgroundAction.cs +++ b/src/Files.App/Actions/Content/Background/SetAsAppBackgroundAction.cs @@ -8,10 +8,10 @@ internal sealed partial class SetAsAppBackgroundAction : BaseSetAsAction private readonly IAppearanceSettingsService AppearanceSettingsService = Ioc.Default.GetRequiredService(); public override string Label - => "SetAsAppBackground".GetLocalizedResource(); + => Strings.SetAsAppBackground.GetLocalizedResource(); public override string Description - => "SetAsAppBackgroundDescription".GetLocalizedResource(); + => Strings.SetAsAppBackgroundDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uE91B"); diff --git a/src/Files.App/Actions/Content/Background/SetAsLockscreenBackgroundAction.cs b/src/Files.App/Actions/Content/Background/SetAsLockscreenBackgroundAction.cs index d5478264dc6b..5723e4a4e1b6 100644 --- a/src/Files.App/Actions/Content/Background/SetAsLockscreenBackgroundAction.cs +++ b/src/Files.App/Actions/Content/Background/SetAsLockscreenBackgroundAction.cs @@ -10,10 +10,10 @@ internal sealed partial class SetAsLockscreenBackgroundAction : BaseSetAsAction private readonly IWindowsWallpaperService WindowsWallpaperService = Ioc.Default.GetRequiredService(); public override string Label - => "SetAsLockscreen".GetLocalizedResource(); + => Strings.SetAsLockscreen.GetLocalizedResource(); public override string Description - => "SetAsLockscreenBackgroundDescription".GetLocalizedResource(); + => Strings.SetAsLockscreenBackgroundDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uEE3F"); diff --git a/src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs b/src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs index 72291e69c652..a903222eac62 100644 --- a/src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs +++ b/src/Files.App/Actions/Content/Background/SetAsSlideshowBackgroundAction.cs @@ -10,10 +10,10 @@ internal sealed partial class SetAsSlideshowBackgroundAction : BaseSetAsAction private readonly IWindowsWallpaperService WindowsWallpaperService = Ioc.Default.GetRequiredService(); public override string Label - => "SetAsSlideshow".GetLocalizedResource(); + => Strings.SetAsSlideshow.GetLocalizedResource(); public override string Description - => "SetAsSlideshowBackgroundDescription".GetLocalizedResource(); + => Strings.SetAsSlideshowBackgroundDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uE91B"); diff --git a/src/Files.App/Actions/Content/Background/SetAsWallpaperBackgroundAction.cs b/src/Files.App/Actions/Content/Background/SetAsWallpaperBackgroundAction.cs index 52108e4671c7..01e4775cdd31 100644 --- a/src/Files.App/Actions/Content/Background/SetAsWallpaperBackgroundAction.cs +++ b/src/Files.App/Actions/Content/Background/SetAsWallpaperBackgroundAction.cs @@ -8,10 +8,10 @@ namespace Files.App.Actions internal sealed partial class SetAsWallpaperBackgroundAction : BaseSetAsAction { public override string Label - => "SetAsBackground".GetLocalizedResource(); + => Strings.SetAsBackground.GetLocalizedResource(); public override string Description - => "SetAsWallpaperBackgroundDescription".GetLocalizedResource(); + => Strings.SetAsWallpaperBackgroundDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uE91B"); diff --git a/src/Files.App/Actions/Content/ImageManipulation/RotateLeftAction.cs b/src/Files.App/Actions/Content/ImageManipulation/RotateLeftAction.cs index 4c1bde731492..b281bbc8e0d9 100644 --- a/src/Files.App/Actions/Content/ImageManipulation/RotateLeftAction.cs +++ b/src/Files.App/Actions/Content/ImageManipulation/RotateLeftAction.cs @@ -8,10 +8,10 @@ namespace Files.App.Actions internal sealed partial class RotateLeftAction : BaseRotateAction { public override string Label - => "RotateLeft".GetLocalizedResource(); + => Strings.RotateLeft.GetLocalizedResource(); public override string Description - => "RotateLeftDescription".GetLocalizedResource(); + => Strings.RotateLeftDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.ImageRotate.ACW"); diff --git a/src/Files.App/Actions/Content/ImageManipulation/RotateRightAction.cs b/src/Files.App/Actions/Content/ImageManipulation/RotateRightAction.cs index 57ea8461a95e..68ca0393ce30 100644 --- a/src/Files.App/Actions/Content/ImageManipulation/RotateRightAction.cs +++ b/src/Files.App/Actions/Content/ImageManipulation/RotateRightAction.cs @@ -8,10 +8,10 @@ namespace Files.App.Actions internal sealed partial class RotateRightAction : BaseRotateAction { public override string Label - => "RotateRight".GetLocalizedResource(); + => Strings.RotateRight.GetLocalizedResource(); public override string Description - => "RotateRightDescription".GetLocalizedResource(); + => Strings.RotateRightDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.ImageRotate.CW");