Skip to content

Fix: Fixed issue where items in the Tags widget were not localized #13149

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

Merged
merged 3 commits into from
Aug 13, 2023
Merged
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
8 changes: 4 additions & 4 deletions src/Files.App.Storage/NativeStorage/NativeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace Files.App.Storage.NativeStorage
/// <inheritdoc cref="IFile"/>
public class NativeFile : NativeStorable<FileInfo>, ILocatableFile, IModifiableFile, IFileExtended, INestedFile
{
public NativeFile(FileInfo fileInfo)
: base(fileInfo)
public NativeFile(FileInfo fileInfo, string? name = null)
: base(fileInfo, name)
{
}

public NativeFile(string path)
: this(new FileInfo(path))
public NativeFile(string path, string? name = null)
: this(new FileInfo(path), name)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App.Storage/NativeStorage/NativeFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ namespace Files.App.Storage.NativeStorage
/// <inheritdoc cref="IFolder"/>
public class NativeFolder : NativeStorable<DirectoryInfo>, ILocatableFolder, IModifiableFolder, IMutableFolder, IFolderExtended, INestedFolder, IDirectCopy, IDirectMove
{
public NativeFolder(DirectoryInfo directoryInfo)
: base(directoryInfo)
public NativeFolder(DirectoryInfo directoryInfo, string? name = null)
: base(directoryInfo, name)
{
}

public NativeFolder(string path)
: this(new DirectoryInfo(path))
public NativeFolder(string path, string? name = null)
: this(new DirectoryInfo(path), name)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App.Storage/NativeStorage/NativeStorable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public abstract class NativeStorable<TStorage> : ILocatableStorable, INestedStor
protected readonly TStorage storage;

/// <inheritdoc/>
public virtual string Path { get; protected set; }
public string Path { get; protected set; }

/// <inheritdoc/>
public virtual string Name { get; protected set; }
public string Name { get; protected set; }

/// <inheritdoc/>
public virtual string Id { get; }

protected NativeStorable(TStorage storage)
protected NativeStorable(TStorage storage, string? name = null)
{
this.storage = storage;
Path = storage.FullName;
Name = storage.Name;
Name = name ?? storage.Name;
Id = storage.FullName;
}

Expand Down
27 changes: 24 additions & 3 deletions src/Files.App.Storage/NativeStorage/NativeStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// Licensed under the MIT License. See the LICENSE.

using Files.Core.Storage;
using Files.Core.Storage.LocatableStorage;
using Files.Shared.Helpers;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Windows.Storage;

namespace Files.App.Storage.NativeStorage
{
Expand All @@ -22,12 +24,31 @@ public Task<IFile> GetFileAsync(string id, CancellationToken cancellationToken =
}

/// <inheritdoc/>
public Task<IFolder> GetFolderAsync(string id, CancellationToken cancellationToken = default)
public async Task<IFolder> GetFolderAsync(string id, CancellationToken cancellationToken = default)
{
if (!Directory.Exists(id))
throw new DirectoryNotFoundException();

return Task.FromResult<IFolder>(new NativeFolder(id));
// A special folder should use the localized name
if (PathHelpers.IsSpecialFolder(id))
{
var storageFolder = await TryGetStorageFolderAsync(id);
return new NativeFolder(id, storageFolder?.DisplayName);
Copy link
Member Author

@d2dyno1 d2dyno1 Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gave92 Do you know a shell method to do it without the Windows.Storage.* overhead? I've searched the docs but the methods there don't accept a specific culture (in this case it would be the app's current culture)

}

return new NativeFolder(id);

async Task<StorageFolder?> TryGetStorageFolderAsync(string path)
{
try
{
return await StorageFolder.GetFolderFromPathAsync(path);
}
catch (Exception)
{
return null;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using System.IO;

namespace Files.App.Actions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
using Files.Shared.Helpers;

namespace Files.App.Actions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Content/Install/InstallFontAction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
using Files.Shared.Helpers;

namespace Files.App.Actions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
using Files.Shared.Helpers;

namespace Files.App.Actions
{
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/Content/PlayAllAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;

namespace Files.App.Actions
{
internal class PlayAllAction : ObservableObject, IAction
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/Content/Run/RunAsAdminAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;

namespace Files.App.Actions
{
internal class RunAsAdminAction : ObservableObject, IAction
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Actions/Content/Run/RunAsAnotherUserAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;

namespace Files.App.Actions
{
internal class RunAsAnotherUserAction : ObservableObject, IAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Shell;
using Files.Shared.Helpers;

namespace Files.App.Actions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Files.Core.Helpers;
using Microsoft.UI.Xaml;
using Windows.Storage;
using Files.Shared.Helpers;

namespace Files.App.Data.Factories
{
Expand Down
6 changes: 1 addition & 5 deletions src/Files.App/Data/Items/ListedItem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Utils.Cloud;
using Files.App.ViewModels.Properties;
using Files.Core.Helpers;
using Files.Core.ViewModels.FileTags;
using Files.Shared.Helpers;
using FluentFTP;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;
using System.IO;
using System.Text;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Files.App.ViewModels.Previews;
using Files.Core.Services.SizeProvider;
using Files.Shared.Helpers;
using LibGit2Sharp;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.Properties;
using Files.Shared.Helpers;

namespace Files.App.Data.Models
{
Expand Down
3 changes: 0 additions & 3 deletions src/Files.App/Data/Models/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI;
using Files.App.Data.Items;
using Files.App.Services;
using Files.App.UserControls.Widgets;
using System.Collections.Specialized;
using System.IO;
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Helpers/MenuFlyout/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.LayoutModes;
using Files.Shared.Helpers;
using Files.App.Helpers.ContextFlyouts;
using Files.App.ViewModels.LayoutModes;
using Microsoft.UI.Xaml.Controls;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Helpers/MenuFlyout/ShellContextMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using CommunityToolkit.WinUI.UI;
using Files.App.Helpers.ContextFlyouts;
using Files.Shared.Helpers;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down
14 changes: 1 addition & 13 deletions src/Files.App/Helpers/Navigation/NavigationHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Extensions;
using Files.App.Utils;
using Files.App.Utils.Shell;
using Files.App.ViewModels;
using Files.App.Views;
using Files.Core.Helpers;
using Files.Core.Services.Settings;
using Files.Shared;
using Files.Shared.Helpers;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Search;
using Windows.System;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Utils/Archives/ArchiveHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.Dialogs;
using Files.App.Utils.Archives;
using Files.App.ViewModels.Dialogs;
using Files.Shared.Helpers;
using Microsoft.UI.Xaml.Controls;
using System.IO;
using System.Text;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Utils/Shell/LaunchHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.Extensions.Logging;
using System.IO;
using System.Text.RegularExpressions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml.Media.Imaging;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using Files.Core.Services.SizeProvider;
using Files.Shared.Helpers;
using Microsoft.UI.Xaml.Media.Imaging;
using System.IO;
using Vanara.PInvoke;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.Extensions.Logging;
using Microsoft.Win32;
using System.Collections.Concurrent;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Windows.Storage;
using Windows.Storage.FileProperties;

Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Utils/Storage/Helpers/StorageHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using System.Runtime.InteropServices;
using Windows.Storage;
using Windows.Storage.FileProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.UI.Xaml.Controls;
using System.IO;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using SevenZip;
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;
Expand Down
3 changes: 1 addition & 2 deletions src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using SevenZip;
using SQLitePCL;
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright(c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Shared.Helpers;
using Microsoft.UI.Dispatching;
using System.IO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Files.App.UserControls.FilePreviews;
using Files.App.ViewModels.Previews;
using Files.Shared.Helpers;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System.Windows.Input;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/ViewModels/UserControls/ToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI.UI;
using Files.Shared.Helpers;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down
Loading