From d00211c56841c7fc6224e956f0a38930465458c3 Mon Sep 17 00:00:00 2001 From: ashutosh nigam Date: Sun, 2 Mar 2025 15:49:32 +0530 Subject: [PATCH 1/3] 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 ea4a6beb58d8b2e2b90e60743984f94e67d4b4ef Mon Sep 17 00:00:00 2001 From: ashutosh nigam <8054735+mrashutoshnigam@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:07:24 +0530 Subject: [PATCH 2/3] Update localization strings in action classes Replaced hardcoded string keys in `RunAsAdminAction`, `RunAsAnotherUserAction`, and `RunWithPowershellAction` with new keys from the `Strings` class for better organization and management of localization resources. --- src/Files.App/Actions/Content/Run/RunAsAdminAction.cs | 4 ++-- src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs | 4 ++-- src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs b/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs index b6d96450fbf7..32990f25011b 100644 --- a/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs +++ b/src/Files.App/Actions/Content/Run/RunAsAdminAction.cs @@ -10,10 +10,10 @@ internal sealed partial class RunAsAdminAction : BaseRunAsAction private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); public override string Label - => "RunAsAdministrator".GetLocalizedResource(); + => Strings.RunAsAdministrator.GetLocalizedResource(); public override string Description - => "RunAsAdminDescription".GetLocalizedResource(); + => Strings.RunAsAdminDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uE7EF"); diff --git a/src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs b/src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs index 05f16040560c..8314ef6cab42 100644 --- a/src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs +++ b/src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs @@ -9,10 +9,10 @@ internal sealed partial class RunAsAnotherUserAction : BaseRunAsAction { private readonly IContentPageContext ContentPageContext = Ioc.Default.GetRequiredService(); public override string Label - => "BaseLayoutContextFlyoutRunAsAnotherUser/Text".GetLocalizedResource(); + => Strings.BaseLayoutContextFlyoutRunAsAnotherUser_Text.GetLocalizedResource(); public override string Description - => "RunAsAnotherUserDescription".GetLocalizedResource(); + => Strings.RunAsAnotherUserDescription.GetLocalizedResource(); public override RichGlyph Glyph => new("\uE7EE"); diff --git a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs index 29577f0cac9c..6e964eef36e6 100644 --- a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs +++ b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs @@ -10,10 +10,10 @@ internal sealed partial class RunWithPowershellAction : ObservableObject, IActio private readonly IContentPageContext context; public string Label - => "RunWithPowerShell".GetLocalizedResource(); + => Strings.RunWithPowerShell.GetLocalizedResource(); public string Description - => "RunWithPowershellDescription".GetLocalizedResource(); + => Strings.RunWithPowershellDescription.GetLocalizedResource(); public RichGlyph Glyph => new("\uE756"); From 9d581c5f82fed5704ed84d7ccceffe9a50a6f891 Mon Sep 17 00:00:00 2001 From: ashutosh nigam <8054735+mrashutoshnigam@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:09:48 +0530 Subject: [PATCH 3/3] Update localization in action classes Refactor `Label` and `Description` properties in `ClearSelectionAction`, `InvertSelectionAction`, `SelectAllAction`, and `ToggleSelectAction` to use the `Strings` class for localization instead of hardcoded string keys. This change enhances maintainability and consistency in localization handling across the application. --- .../Actions/Content/Selection/ClearSelectionAction.cs | 4 ++-- .../Actions/Content/Selection/InvertSelectionAction.cs | 4 ++-- src/Files.App/Actions/Content/Selection/SelectAllAction.cs | 4 ++-- src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs index d967131526f2..a7e44beb059c 100644 --- a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs @@ -8,10 +8,10 @@ internal sealed class ClearSelectionAction : IAction private readonly IContentPageContext context; public string Label - => "ClearSelection".GetLocalizedResource(); + => Strings.ClearSelection.GetLocalizedResource(); public string Description - => "ClearSelectionDescription".GetLocalizedResource(); + => Strings.ClearSelectionDescription.GetLocalizedResource(); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.SelectNone"); diff --git a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs index aecf60cc1dca..8054e9d0450e 100644 --- a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs @@ -8,10 +8,10 @@ internal sealed class InvertSelectionAction : IAction private readonly IContentPageContext context; public string Label - => "InvertSelection".GetLocalizedResource(); + => Strings.InvertSelection.GetLocalizedResource(); public string Description - => "InvertSelectionDescription".GetLocalizedResource(); + => Strings.InvertSelectionDescription.GetLocalizedResource(); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.SelectInvert"); diff --git a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs index aaa62b4f285c..5f3aae630853 100644 --- a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs +++ b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs @@ -8,10 +8,10 @@ internal sealed class SelectAllAction : IAction private readonly IContentPageContext context; public string Label - => "SelectAll".GetLocalizedResource(); + => Strings.SelectAll.GetLocalizedResource(); public string Description - => "SelectAllDescription".GetLocalizedResource(); + => Strings.SelectAllDescription.GetLocalizedResource(); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.SelectAll"); diff --git a/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs b/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs index b9a91b53bf73..41475710d0b1 100644 --- a/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs +++ b/src/Files.App/Actions/Content/Selection/ToggleSelectAction.cs @@ -9,10 +9,10 @@ namespace Files.App.Actions internal sealed class ToggleSelectAction : IAction { public string Label - => "ToggleSelect".GetLocalizedResource(); + => Strings.ToggleSelect.GetLocalizedResource(); public string Description - => "ToggleSelectDescription".GetLocalizedResource(); + => Strings.ToggleSelectDescription.GetLocalizedResource(); public HotKey HotKey => new(Keys.Space, KeyModifiers.Ctrl);