Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Enforced centralized Strings class in misc UI code behind #16940

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Files.App/Dialogs/CreateArchiveDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,28 @@ public string Password

public ImmutableList<CompressionLevelItem> CompressionLevels { get; } =
[
new CompressionLevelItem(ArchiveCompressionLevels.Ultra, "CompressionLevelUltra".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.High, "CompressionLevelHigh".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Normal, "CompressionLevelNormal".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Low, "CompressionLevelLow".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Fast, "CompressionLevelFast".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.None, "CompressionLevelNone".GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Ultra, Strings.CompressionLevelUltra.GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.High, Strings.CompressionLevelHigh.GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Normal, Strings.CompressionLevelNormal.GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Low, Strings.CompressionLevelLow.GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.Fast, Strings.CompressionLevelFast.GetLocalizedResource()),
new CompressionLevelItem(ArchiveCompressionLevels.None, Strings.CompressionLevelNone.GetLocalizedResource()),
];

public ImmutableList<SplittingSizeItem> SplittingSizes { get; } =
[
new(ArchiveSplittingSizes.None, "Do not split".GetLocalizedResource()),
new(ArchiveSplittingSizes.None, Strings.Do_not_split.GetLocalizedResource()),
new(ArchiveSplittingSizes.Mo10, ToSizeText(10)),
new(ArchiveSplittingSizes.Mo100, ToSizeText(100)),
new(ArchiveSplittingSizes.Cd650, ToSizeText(650), "CD".GetLocalizedResource()),
new(ArchiveSplittingSizes.Cd700, ToSizeText(700), "CD".GetLocalizedResource()),
new(ArchiveSplittingSizes.Cd650, ToSizeText(650), Strings.CD.GetLocalizedResource()),
new(ArchiveSplittingSizes.Cd700, ToSizeText(700), Strings.CD.GetLocalizedResource()),
new(ArchiveSplittingSizes.Mo1024, ToSizeText(1024)),
new(ArchiveSplittingSizes.Mo2048, ToSizeText(2048)),
new(ArchiveSplittingSizes.Fat4092, ToSizeText(4092), "FAT".GetLocalizedResource()),
new(ArchiveSplittingSizes.Dvd4480, ToSizeText(4480), "DVD".GetLocalizedResource()),
new(ArchiveSplittingSizes.Fat4092, ToSizeText(4092), Strings.FAT.GetLocalizedResource()),
new(ArchiveSplittingSizes.Dvd4480, ToSizeText(4480), Strings.DVD.GetLocalizedResource()),
new(ArchiveSplittingSizes.Mo5120, ToSizeText(5120)),
new(ArchiveSplittingSizes.Dvd8128, ToSizeText(8128), "DVD".GetLocalizedResource()),
new(ArchiveSplittingSizes.Bd23040, ToSizeText(23040), "Bluray".GetLocalizedResource()),
new(ArchiveSplittingSizes.Dvd8128, ToSizeText(8128), Strings.DVD.GetLocalizedResource()),
new(ArchiveSplittingSizes.Bd23040, ToSizeText(23040), Strings.Bluray.GetLocalizedResource()),
];

public DialogViewModel()
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void DragOver_SetCaptions(LocationItem senderLocationItem, LocationItem
else
{
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.Caption = "MoveItemsDialogPrimaryButtonText".GetLocalizedResource();
e.DragUIOverride.Caption = Strings.MoveItemsDialogPrimaryButtonText.GetLocalizedResource();
e.AcceptedOperation = DataPackageOperation.Move;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/UserControls/TabBar/TabBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void TabView_TabStripDragOver(object sender, DragEventArgs e)
HorizontalTabView.CanReorderTabs = WindowContext.CanDragAndDrop;

e.AcceptedOperation = DataPackageOperation.Move;
e.DragUIOverride.Caption = "TabStripDragAndDropUIOverrideCaption".GetLocalizedResource();
e.DragUIOverride.Caption = Strings.TabStripDragAndDropUIOverrideCaption.GetLocalizedResource();
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.IsGlyphVisible = false;
}
Expand Down Expand Up @@ -333,7 +333,7 @@ private async void TabBarAddNewTabButton_DragOver(object sender, DragEventArgs e
e.Handled = true;
var deferral = e.GetDeferral();
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.Caption = string.Format("OpenInNewTab".GetLocalizedResource());
e.DragUIOverride.Caption = string.Format(Strings.OpenInNewTab.GetLocalizedResource());
e.AcceptedOperation = DataPackageOperation.Link;
deferral.Complete();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)

string componentLabel =
parameters?.NavPathParam == "Home"
? "Home".GetLocalizedResource()
? Strings.Home.GetLocalizedResource()
: parameters?.NavPathParam
?? string.Empty;

Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
{
var promptForReviewDialog = new ContentDialog
{
Title = "ReviewFiles".ToLocalized(),
Content = "ReviewFilesContent".ToLocalized(),
PrimaryButtonText = "Yes".ToLocalized(),
SecondaryButtonText = "No".ToLocalized()
Title = Strings.ReviewFiles.ToLocalized(),
Content = Strings.ReviewFilesContent.ToLocalized(),
PrimaryButtonText = Strings.Yes.ToLocalized(),
SecondaryButtonText = Strings.No.ToLocalized()
};

if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
Expand Down Expand Up @@ -95,10 +95,10 @@
{
var runningAsAdminPrompt = new ContentDialog
{
Title = "FilesRunningAsAdmin".ToLocalized(),
Content = "FilesRunningAsAdminContent".ToLocalized(),
PrimaryButtonText = "Ok".ToLocalized(),
SecondaryButtonText = "DontShowAgain".ToLocalized()
Title = Strings.FilesRunningAsAdmin.ToLocalized(),
Content = Strings.FilesRunningAsAdminContent.ToLocalized(),
PrimaryButtonText = Strings.Ok.ToLocalized(),

Check failure on line 100 in src/Files.App/Views/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

'Strings' does not contain a definition for 'Ok'

Check failure on line 100 in src/Files.App/Views/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

'Strings' does not contain a definition for 'Ok'

Check failure on line 100 in src/Files.App/Views/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

'Strings' does not contain a definition for 'Ok'

Check failure on line 100 in src/Files.App/Views/MainPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

'Strings' does not contain a definition for 'Ok'
SecondaryButtonText = Strings.DontShowAgain.ToLocalized()
};

var result = await SetContentDialogRoot(runningAsAdminPrompt).TryShowAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve
if (ContentPage is null)
return;

var directoryItemCountLocalization = "Items".GetLocalizedFormatResource(ShellViewModel.FilesAndFolders.Count);
var directoryItemCountLocalization = Strings.Items.GetLocalizedFormatResource(ShellViewModel.FilesAndFolders.Count);

BranchItem? headBranch = headBranch = InstanceViewModel.IsGitRepository
? await GitHelpers.GetRepositoryHead(InstanceViewModel.GitRepositoryPath)
Expand Down Expand Up @@ -759,7 +759,7 @@ await DispatcherQueue.EnqueueOrInvokeAsync(async () =>
protected void SelectSidebarItemFromPath(Type incomingSourcePageType = null)
{
if (incomingSourcePageType == typeof(HomePage) && incomingSourcePageType is not null)
ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource();
ToolbarViewModel.PathControlDisplayText = Strings.Home.GetLocalizedResource();
}

protected void SetLoadingIndicatorForTabs(bool isLoading)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Shells/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ModernShellPage() : base(new CurrentInstanceViewModel())
ShellViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent;
ShellViewModel.GitDirectoryUpdated += FilesystemViewModel_GitDirectoryUpdated;

ToolbarViewModel.PathControlDisplayText = "Home".GetLocalizedResource();
ToolbarViewModel.PathControlDisplayText = Strings.Home.GetLocalizedResource();
ToolbarViewModel.RefreshWidgetsRequested += ModernShellPage_RefreshWidgetsRequested;

_navigationInteractionTracker = new NavigationInteractionTracker(this, BackIcon, ForwardIcon);
Expand Down
Loading