From d00211c56841c7fc6224e956f0a38930465458c3 Mon Sep 17 00:00:00 2001 From: ashutosh nigam Date: Sun, 2 Mar 2025 15:49:32 +0530 Subject: [PATCH 1/4] 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 9ee0f29a03056e076e8cfa4707fc426ab197e19b Mon Sep 17 00:00:00 2001 From: ashutosh nigam <8054735+mrashutoshnigam@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:42:16 +0530 Subject: [PATCH 2/4] Update localization strings in action classes Refactor `Label` and `Description` properties in `PlayAllAction`, `RefreshItemsAction`, `ShareItemAction`, and `OpenAllTaggedActions` to use a centralized `Strings` class for improved maintainability and consistency in localization across the application. --- src/Files.App/Actions/Content/PlayAllAction.cs | 4 ++-- src/Files.App/Actions/Content/RefreshItemsAction.cs | 4 ++-- src/Files.App/Actions/Content/Share/ShareItemAction.cs | 4 ++-- src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Files.App/Actions/Content/PlayAllAction.cs b/src/Files.App/Actions/Content/PlayAllAction.cs index 4763195bf559..ee455cb5414d 100644 --- a/src/Files.App/Actions/Content/PlayAllAction.cs +++ b/src/Files.App/Actions/Content/PlayAllAction.cs @@ -10,10 +10,10 @@ internal sealed partial class PlayAllAction : ObservableObject, IAction private readonly IContentPageContext context; public string Label - => "PlayAll".GetLocalizedResource(); + => Strings.PlayAll.GetLocalizedResource(); public string Description - => "PlayAllDescription".GetLocalizedResource(); + => Strings.PlayAllDescription.GetLocalizedResource(); public RichGlyph Glyph => new("\uE768"); diff --git a/src/Files.App/Actions/Content/RefreshItemsAction.cs b/src/Files.App/Actions/Content/RefreshItemsAction.cs index 91fee4ecdb66..a52fa26e08b9 100644 --- a/src/Files.App/Actions/Content/RefreshItemsAction.cs +++ b/src/Files.App/Actions/Content/RefreshItemsAction.cs @@ -8,10 +8,10 @@ internal sealed partial class RefreshItemsAction : ObservableObject, IAction private readonly IContentPageContext context; public string Label - => "Refresh".GetLocalizedResource(); + => Strings.Refresh.GetLocalizedResource(); public string Description - => "RefreshItemsDescription".GetLocalizedResource(); + => Strings.RefreshItemsDescription.GetLocalizedResource(); public RichGlyph Glyph => new("\uE72C"); diff --git a/src/Files.App/Actions/Content/Share/ShareItemAction.cs b/src/Files.App/Actions/Content/Share/ShareItemAction.cs index 5f3d9f15c269..0077976bfed4 100644 --- a/src/Files.App/Actions/Content/Share/ShareItemAction.cs +++ b/src/Files.App/Actions/Content/Share/ShareItemAction.cs @@ -10,10 +10,10 @@ internal sealed partial class ShareItemAction : ObservableObject, IAction private readonly IContentPageContext context; public string Label - => "Share".GetLocalizedResource(); + => Strings.Share.GetLocalizedResource(); public string Description - => "ShareItemDescription".GetLocalizedResource(); + => Strings.ShareItemDescription.GetLocalizedResource(); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.Share"); diff --git a/src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs b/src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs index 42e70e19c4ed..e6492509db41 100644 --- a/src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs +++ b/src/Files.App/Actions/Content/Tags/OpenAllTaggedActions.cs @@ -10,10 +10,10 @@ sealed partial class OpenAllTaggedActions: ObservableObject, IAction private readonly ITagsContext _tagsContext; public string Label - => "OpenAllTaggedItems".GetLocalizedResource(); + => Strings.OpenAllTaggedItems.GetLocalizedResource(); public string Description - => "OpenAllTaggedItemsDescription".GetLocalizedResource(); + => Strings.OpenAllTaggedItemsDescription.GetLocalizedResource(); public RichGlyph Glyph => new("\uE71D"); From 5fad2572ee8e5f3109cf9fd57d9a4654111e103c Mon Sep 17 00:00:00 2001 From: ashutosh nigam <8054735+mrashutoshnigam@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:49:03 +0530 Subject: [PATCH 3/4] Update localization strings in action classes Refactor the `Label` and `Description` properties in the `GroupAction`, `SortFilesAndFoldersTogetherAction`, `SortFilesFirstAction`, and `SortFoldersFirstAction` classes to utilize a new `Strings` resource class. This improves maintainability and consistency of localization across the application. --- src/Files.App/Actions/Display/GroupAction.cs | 4 ++-- .../Actions/Display/SortFilesAndFoldersTogetherAction.cs | 4 ++-- src/Files.App/Actions/Display/SortFilesFirstAction.cs | 4 ++-- src/Files.App/Actions/Display/SortFoldersFirstAction.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Files.App/Actions/Display/GroupAction.cs b/src/Files.App/Actions/Display/GroupAction.cs index 6bf54e49d2a9..5904f3f7a9a3 100644 --- a/src/Files.App/Actions/Display/GroupAction.cs +++ b/src/Files.App/Actions/Display/GroupAction.cs @@ -9,10 +9,10 @@ protected override GroupOption GroupOption => GroupOption.None; public override string Label - => "None".GetLocalizedResource(); + => Strings.None.GetLocalizedResource(); public override string Description - => "GroupByNoneDescription".GetLocalizedResource(); + => Strings.GroupByNoneDescription.GetLocalizedResource(); } internal sealed partial class GroupByNameAction : GroupByAction diff --git a/src/Files.App/Actions/Display/SortFilesAndFoldersTogetherAction.cs b/src/Files.App/Actions/Display/SortFilesAndFoldersTogetherAction.cs index 633bf34b709c..da9e133f30c2 100644 --- a/src/Files.App/Actions/Display/SortFilesAndFoldersTogetherAction.cs +++ b/src/Files.App/Actions/Display/SortFilesAndFoldersTogetherAction.cs @@ -8,10 +8,10 @@ internal sealed partial class SortFilesAndFoldersTogetherAction : ObservableObje private readonly IDisplayPageContext context; public string Label - => "SortFilesAndFoldersTogether".GetLocalizedResource(); + => Strings.SortFilesAndFoldersTogether.GetLocalizedResource(); public string Description - => "SortFilesAndFoldersTogetherDescription".GetLocalizedResource(); + => Strings.SortFilesAndFoldersTogetherDescription.GetLocalizedResource(); public bool IsOn => context.SortDirectoriesAlongsideFiles; diff --git a/src/Files.App/Actions/Display/SortFilesFirstAction.cs b/src/Files.App/Actions/Display/SortFilesFirstAction.cs index d2adfcf905ef..6ea001074766 100644 --- a/src/Files.App/Actions/Display/SortFilesFirstAction.cs +++ b/src/Files.App/Actions/Display/SortFilesFirstAction.cs @@ -8,10 +8,10 @@ internal sealed partial class SortFilesFirstAction : ObservableObject, IToggleAc private readonly IDisplayPageContext context; public string Label - => "SortFilesFirst".GetLocalizedResource(); + => Strings.SortFilesFirst.GetLocalizedResource(); public string Description - => "SortFilesFirstDescription".GetLocalizedResource(); + => Strings.SortFilesFirstDescription.GetLocalizedResource(); public bool IsOn => context.SortFilesFirst && !context.SortDirectoriesAlongsideFiles; diff --git a/src/Files.App/Actions/Display/SortFoldersFirstAction.cs b/src/Files.App/Actions/Display/SortFoldersFirstAction.cs index 731543e63ad7..128f4560f984 100644 --- a/src/Files.App/Actions/Display/SortFoldersFirstAction.cs +++ b/src/Files.App/Actions/Display/SortFoldersFirstAction.cs @@ -8,10 +8,10 @@ internal sealed partial class SortFoldersFirstAction : ObservableObject, IToggle private readonly IDisplayPageContext context; public string Label - => "SortFoldersFirst".GetLocalizedResource(); + => Strings.SortFoldersFirst.GetLocalizedResource(); public string Description - => "SortFoldersFirstDescription".GetLocalizedResource(); + => Strings.SortFoldersFirstDescription.GetLocalizedResource(); public bool IsOn => !context.SortFilesFirst && !context.SortDirectoriesAlongsideFiles; From f8eb959c25275cdfae46cf4c20cfad0f63307fa3 Mon Sep 17 00:00:00 2001 From: ashutosh nigam <8054735+mrashutoshnigam@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:49:52 +0530 Subject: [PATCH 4/4] Update localization strings in SortAction.cs Refactor localization for sorting actions to use a centralized Strings class instead of hardcoded keys. This change enhances maintainability and consistency across various sorting options, including name, date modified, date created, size, file type, sync status, file tag, path, original folder, date deleted, and sorting direction (ascending and descending). --- src/Files.App/Actions/Display/SortAction.cs | 52 ++++++++++----------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Files.App/Actions/Display/SortAction.cs b/src/Files.App/Actions/Display/SortAction.cs index 6e06ca05204d..702b4cc1e01d 100644 --- a/src/Files.App/Actions/Display/SortAction.cs +++ b/src/Files.App/Actions/Display/SortAction.cs @@ -9,10 +9,10 @@ protected override SortOption SortOption => SortOption.Name; public override string Label - => "Name".GetLocalizedResource(); + => Strings.Name.GetLocalizedResource(); public override string Description - => "SortByNameDescription".GetLocalizedResource(); + => Strings.SortByNameDescription.GetLocalizedResource(); } internal sealed partial class SortByDateModifiedAction : SortByAction @@ -21,10 +21,10 @@ protected override SortOption SortOption => SortOption.DateModified; public override string Label - => "DateModifiedLowerCase".GetLocalizedResource(); + => Strings.DateModifiedLowerCase.GetLocalizedResource(); public override string Description - => "SortByDateModifiedDescription".GetLocalizedResource(); + => Strings.SortByDateModifiedDescription.GetLocalizedResource(); } internal sealed partial class SortByDateCreatedAction : SortByAction @@ -33,10 +33,10 @@ protected override SortOption SortOption => SortOption.DateCreated; public override string Label - => "DateCreated".GetLocalizedResource(); + => Strings.DateCreated.GetLocalizedResource(); public override string Description - => "SortByDateCreatedDescription".GetLocalizedResource(); + => Strings.SortByDateCreatedDescription.GetLocalizedResource(); } internal sealed partial class SortBySizeAction : SortByAction @@ -45,10 +45,10 @@ protected override SortOption SortOption => SortOption.Size; public override string Label - => "Size".GetLocalizedResource(); + => Strings.Size.GetLocalizedResource(); public override string Description - => "SortBySizeDescription".GetLocalizedResource(); + => Strings.SortBySizeDescription.GetLocalizedResource(); } internal sealed partial class SortByTypeAction : SortByAction @@ -57,10 +57,10 @@ protected override SortOption SortOption => SortOption.FileType; public override string Label - => "Type".GetLocalizedResource(); + => Strings.Type.GetLocalizedResource(); public override string Description - => "SortByTypeDescription".GetLocalizedResource(); + => Strings.SortByTypeDescription.GetLocalizedResource(); } internal sealed partial class SortBySyncStatusAction : SortByAction @@ -69,10 +69,10 @@ protected override SortOption SortOption => SortOption.SyncStatus; public override string Label - => "SyncStatus".GetLocalizedResource(); + => Strings.SyncStatus.GetLocalizedResource(); public override string Description - => "SortBySyncStatusDescription".GetLocalizedResource(); + => Strings.SortBySyncStatusDescription.GetLocalizedResource(); protected override bool GetIsExecutable(ContentPageTypes pageType) => pageType is ContentPageTypes.CloudDrive; @@ -84,10 +84,10 @@ protected override SortOption SortOption => SortOption.FileTag; public override string Label - => "FileTags".GetLocalizedResource(); + => Strings.FileTags.GetLocalizedResource(); public override string Description - => "SortByTagDescription".GetLocalizedResource(); + => Strings.SortByTagDescription.GetLocalizedResource(); } internal sealed partial class SortByPathAction : SortByAction @@ -96,10 +96,10 @@ protected override SortOption SortOption => SortOption.Path; public override string Label - => "Path".GetLocalizedResource(); + => Strings.Path.GetLocalizedResource(); public override string Description - => "SortByPathDescription".GetLocalizedResource(); + => Strings.SortByPathDescription.GetLocalizedResource(); protected override bool GetIsExecutable(ContentPageTypes pageType) => pageType is ContentPageTypes.SearchResults; @@ -111,10 +111,10 @@ protected override SortOption SortOption => SortOption.OriginalFolder; public override string Label - => "OriginalFolder".GetLocalizedResource(); + => Strings.OriginalFolder.GetLocalizedResource(); public override string Description - => "SortByOriginalFolderDescription".GetLocalizedResource(); + => Strings.SortByOriginalFolderDescription.GetLocalizedResource(); protected override bool GetIsExecutable(ContentPageTypes pageType) => pageType is ContentPageTypes.RecycleBin; @@ -126,10 +126,10 @@ protected override SortOption SortOption => SortOption.DateDeleted; public override string Label - => "DateDeleted".GetLocalizedResource(); + => Strings.DateDeleted.GetLocalizedResource(); public override string Description - => "SortByDateDeletedDescription".GetLocalizedResource(); + => Strings.SortByDateDeletedDescription.GetLocalizedResource(); protected override bool GetIsExecutable(ContentPageTypes pageType) => pageType is ContentPageTypes.RecycleBin; @@ -190,10 +190,10 @@ internal sealed partial class SortAscendingAction : ObservableObject, IToggleAct private readonly IDisplayPageContext context; public string Label - => "Ascending".GetLocalizedResource(); + => Strings.Ascending.GetLocalizedResource(); public string Description - => "SortAscendingDescription".GetLocalizedResource(); + => Strings.SortAscendingDescription.GetLocalizedResource(); public bool IsOn => context.SortDirection is SortDirection.Ascending; @@ -225,10 +225,10 @@ internal sealed partial class SortDescendingAction : ObservableObject, IToggleAc private readonly IDisplayPageContext context; public string Label - => "Descending".GetLocalizedResource(); + => Strings.Descending.GetLocalizedResource(); public string Description - => "SortDescendingDescription".GetLocalizedResource(); + => Strings.SortDescendingDescription.GetLocalizedResource(); public bool IsOn => context.SortDirection is SortDirection.Descending; @@ -260,10 +260,10 @@ internal sealed class ToggleSortDirectionAction : IAction private readonly IDisplayPageContext context; public string Label - => "ToggleSortDirection".GetLocalizedResource(); + => Strings.ToggleSortDirection.GetLocalizedResource(); public string Description - => "ToggleSortDirectionDescription".GetLocalizedResource(); + => Strings.ToggleSortDirectionDescription.GetLocalizedResource(); public ToggleSortDirectionAction() {