diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
index cd178a1..7262596 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3 (Package)/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="1.1.208.0" />
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
index f1b2edb..6769458 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/App.xaml.cs
@@ -6,6 +6,7 @@ using BetterLyrics.WinUI3.Services.AlbumArtSearchService;
using BetterLyrics.WinUI3.Services.DiscordService;
using BetterLyrics.WinUI3.Services.LastFMService;
using BetterLyrics.WinUI3.Services.LibWatcherService;
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Services.LyricsSearchService;
using BetterLyrics.WinUI3.Services.MediaSessionsService;
using BetterLyrics.WinUI3.Services.SettingsService;
@@ -20,14 +21,11 @@ using Microsoft.UI.Xaml;
using Microsoft.Windows.ApplicationModel.Resources;
using Serilog;
using System;
-using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Vanara.PInvoke;
-using Windows.Storage;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3
{
@@ -69,10 +67,8 @@ namespace BetterLyrics.WinUI3
}
}
- protected override async void OnLaunched(LaunchActivatedEventArgs args)
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
{
- await InitializeLocalizer();
-
var settingsService = Ioc.Default.GetRequiredService();
settingsService.UpdateLanguage();
@@ -124,6 +120,7 @@ namespace BetterLyrics.WinUI3
.AddSingleton()
.AddSingleton()
.AddSingleton()
+ .AddSingleton()
// ViewModels
.AddSingleton()
.AddSingleton()
@@ -147,43 +144,6 @@ namespace BetterLyrics.WinUI3
);
}
- private async Task InitializeLocalizer()
- {
- // Initialize a "Strings" folder in the "LocalFolder" for the packaged app.
- StorageFolder localFolder = ApplicationData.Current.LocalFolder;
- StorageFolder stringsFolder = await localFolder.CreateFolderAsync("Strings", CreationCollisionOption.ReplaceExisting);
-
- // Create string resources file from app resources.
- string resourceFileName = "Resources.resw";
- foreach (var item in LanguageHelper.SupportedDisplayLanguages)
- {
- await CreateStringResourceFile(stringsFolder, item.LanguageCode, resourceFileName);
- }
-
- ILocalizer localizer = await new LocalizerBuilder()
- .AddStringResourcesFolderForLanguageDictionaries(stringsFolder.Path)
- .SetOptions(options =>
- {
- options.DefaultLanguage = "en";
- })
- .Build();
- }
-
- private static async Task CreateStringResourceFile(StorageFolder stringsFolder, string language, string resourceFileName)
- {
- StorageFolder languageFolder = await stringsFolder.CreateFolderAsync(language, CreationCollisionOption.ReplaceExisting);
-
- string resourceFilePath = Path.Combine(stringsFolder.Name, language, resourceFileName);
- StorageFile resourceFile = await LoadStringResourcesFileFromAppResource(resourceFilePath);
- _ = await resourceFile.CopyAsync(languageFolder);
- }
-
- private static async Task LoadStringResourcesFileFromAppResource(string filePath)
- {
- Uri resourcesFileUri = new($"ms-appx:///{filePath}");
- return await StorageFile.GetFileFromApplicationUriAsync(resourcesFileUri);
- }
-
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
_logger.LogError(e.Exception, "App_UnhandledException");
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
index 4e60d2a..361b8a1 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/BetterLyrics.WinUI3.csproj
@@ -105,7 +105,6 @@
-
@@ -342,36 +341,6 @@
MSBuild:Compile
-
-
- Always
-
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
- Always
-
-
MSBuild:Compile
@@ -417,6 +386,44 @@
MSBuild:Compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
False
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AboutControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AboutControl.xaml
index 91aac3b..1d6156e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AboutControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/AboutControl.xaml
@@ -7,7 +7,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:helper="using:BetterLyrics.WinUI3.Helper"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
@@ -49,7 +48,7 @@
VerticalAlignment="Center"
Foreground="{ThemeResource TextFillColorSecondaryBrush}">
-
+
@@ -60,9 +59,9 @@
-
-
-
+
+
+
@@ -70,18 +69,18 @@
-
+
-
-
-
+
+
+
-
+
@@ -122,14 +121,14 @@
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/FontFamilyAutoSuggestBox.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/FontFamilyAutoSuggestBox.xaml
index 9085437..6681eab 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/FontFamilyAutoSuggestBox.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/FontFamilyAutoSuggestBox.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:BetterLyrics.WinUI3.Models"
@@ -46,12 +45,12 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
index cd3bfce..74c27a1 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsBackgroundSettingsControl.xaml
@@ -7,7 +7,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:enums="using:BetterLyrics.WinUI3.Enums"
- xmlns:l="using:WinUI3Localizer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -18,25 +17,25 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -134,7 +133,7 @@
@@ -164,7 +163,7 @@
Unit="°"
Value="{x:Bind LyricsEffectSettings.Lyrics3DZAngle, Mode=TwoWay}" />
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -46,9 +45,9 @@
+ VerticalAlignment="Center" />
-
+
@@ -81,9 +80,9 @@
+ VerticalAlignment="Center" />
-
+
@@ -120,7 +119,7 @@
CornerRadius="4">
-
+
@@ -130,9 +129,9 @@
+ VerticalAlignment="Center" />
-
+
-
+
-
+
@@ -181,26 +180,26 @@
Value="{x:Bind Provider, Mode=OneWay, Converter={StaticResource LyricsSearchProviderToDisplayNameConverter}}" />
-
-
-
+
+
+
@@ -270,8 +269,8 @@
@@ -353,19 +352,19 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
index 7bd1fd0..2c32a94 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsStyleSettingsControl.xaml
@@ -7,7 +7,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -20,17 +19,17 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
-
+
+
+
@@ -123,11 +122,11 @@
Color="{x:Bind LyricsStyleSettings.LyricsCustomStrokeFontColor, Mode=TwoWay}" />
-
+
-
-
-
+
+
+
@@ -158,11 +157,11 @@
Color="{x:Bind LyricsStyleSettings.LyricsCustomBgFontColor, Mode=TwoWay}" />
-
+
-
-
-
+
+
+
@@ -196,12 +195,12 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -52,12 +51,12 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
-
+
@@ -87,10 +86,10 @@
Spacing="6">
-
-
+
+
@@ -109,7 +108,7 @@
HorizontalAlignment="Stretch"
Click="SetDefaultMenuFlyoutItem_Click"
IsChecked="{Binding IsDefault, Mode=OneWay}">
-
+
@@ -120,7 +119,7 @@
Grid.Column="0"
HorizontalAlignment="Stretch"
Click="ConfigButton_Click">
-
+
@@ -129,13 +128,13 @@
-
+
-
+
-
+
@@ -192,25 +191,25 @@
Style="{StaticResource PivotSegmentedStyle}">
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -236,19 +235,19 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSwitchControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSwitchControl.xaml
index a064c36..624571c 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSwitchControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/LyricsWindowSwitchControl.xaml
@@ -6,7 +6,6 @@
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -26,10 +25,10 @@
+ VerticalAlignment="Top" />
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
index 16ff776..9f1c532 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/MediaSettingsControl.xaml
@@ -6,7 +6,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:BetterLyrics.WinUI3.Models"
@@ -20,10 +19,10 @@
-
+
-
+
@@ -88,11 +87,11 @@
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/NowPlayingBar.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/NowPlayingBar.xaml
index e118963..b3217d2 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/NowPlayingBar.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/NowPlayingBar.xaml
@@ -5,7 +5,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -294,13 +293,13 @@
@@ -315,7 +314,7 @@
@@ -330,7 +329,7 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
index 875b9d0..162c7cd 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PlaybackSettingsControl.xaml
@@ -10,7 +10,6 @@
xmlns:globalization="using:Windows.Globalization"
xmlns:helper="using:BetterLyrics.WinUI3.Helper"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:BetterLyrics.WinUI3.Models"
@@ -54,7 +53,7 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -295,8 +294,8 @@
@@ -307,30 +306,30 @@
-
+
+ HorizontalContentAlignment="Left">
-
-
+
+
+ HorizontalContentAlignment="Left">
-
-
-
+
+
+
@@ -338,50 +337,50 @@
+ HorizontalContentAlignment="Left">
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
@@ -392,27 +391,27 @@
-
+
-
+
@@ -421,22 +420,22 @@
-
-
+
+
-
-
+
+
-
+
-
+
@@ -446,14 +445,14 @@
@@ -462,46 +461,46 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PropertyRow.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PropertyRow.xaml
index 645da5d..499dc1d 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PropertyRow.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/PropertyRow.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -58,7 +57,7 @@
Click="OnCopyClicked"
Opacity="0">
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml
index 2f861df..b3a0089 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
@@ -24,17 +23,17 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml.cs
index 53595ad..f5710e3 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/RemoteServerConfigControl.xaml.cs
@@ -1,16 +1,17 @@
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Models;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Controls
{
public sealed partial class RemoteServerConfigControl : UserControl
{
private readonly string _protocolType;
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public RemoteServerConfigControl(string protocolType)
{
@@ -42,7 +43,7 @@ namespace BetterLyrics.WinUI3.Controls
public MediaFolder GetConfig()
{
if (string.IsNullOrWhiteSpace(HostBox.Text))
- throw new ArgumentException(_localizer.GetLocalizedString("RemoteServerConfigControlServerAddressRequired"));
+ throw new ArgumentException(_localizationService.GetLocalizedString("RemoteServerConfigControlServerAddressRequired"));
string name = $"{_protocolType} - {HostBox.Text}";
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml
index 87933ea..bbbc549 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -26,7 +25,7 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
index 7691d20..be5452e 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/ShortcutTextBox.xaml.cs
@@ -1,12 +1,13 @@
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Hooks;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using System.Collections.Generic;
using Windows.UI.Core;
-using WinUI3Localizer;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -15,7 +16,7 @@ namespace BetterLyrics.WinUI3.Controls
{
public sealed partial class ShortcutTextBox : UserControl
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public ShortcutTextBox()
{
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/SystemTray.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/SystemTray.xaml
index a546ea9..6eda0c6 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/SystemTray.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/SystemTray.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="using:H.NotifyIcon"
@@ -30,37 +29,37 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/WindowSettingsControl.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/WindowSettingsControl.xaml
index 671e94c..a763b05 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/WindowSettingsControl.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Controls/WindowSettingsControl.xaml
@@ -5,7 +5,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
@@ -16,9 +15,9 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
index 0db2c0d..4c85363 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/AlbumArtSearchProviderToDisplayNameConverter.cs
@@ -1,13 +1,14 @@
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Converter
{
public partial class AlbumArtSearchProviderToDisplayNameConverter : IValueConverter
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public object Convert(object value, Type targetType, object parameter, string language)
{
@@ -15,8 +16,8 @@ namespace BetterLyrics.WinUI3.Converter
{
return provider switch
{
- AlbumArtSearchProvider.Local => _localizer.GetLocalizedString("AlbumArtSearchLocalProvider"),
- AlbumArtSearchProvider.SMTC => _localizer.GetLocalizedString("AlbumArtSearchSMTCProvider"),
+ AlbumArtSearchProvider.Local => _localizationService.GetLocalizedString("AlbumArtSearchLocalProvider"),
+ AlbumArtSearchProvider.SMTC => _localizationService.GetLocalizedString("AlbumArtSearchSMTCProvider"),
AlbumArtSearchProvider.iTunes => "iTunes",
_ => throw new Exception($"Unknown AlbumArtSearchProvider: {provider}"),
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/FileSourceTypeToIconConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/FileSourceTypeToIconConverter.cs
index a4c0d7c..577edf6 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/FileSourceTypeToIconConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/FileSourceTypeToIconConverter.cs
@@ -1,5 +1,4 @@
using BetterLyrics.WinUI3.Enums;
-using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using System;
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
index d1db41d..3423d86 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/LyricsSearchProviderToDisplayNameConverter.cs
@@ -1,15 +1,16 @@
// 2025/6/23 by Zhe Fang
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Converter
{
public partial class LyricsSearchProviderToDisplayNameConverter : IValueConverter
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public object Convert(object value, Type targetType, object parameter, string language)
{
@@ -23,10 +24,10 @@ namespace BetterLyrics.WinUI3.Converter
LyricsSearchProvider.Kugou => "酷狗音乐",
LyricsSearchProvider.AmllTtmlDb => "amll-ttml-db",
LyricsSearchProvider.AppleMusic => "Apple Music",
- LyricsSearchProvider.LocalLrcFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
- LyricsSearchProvider.LocalMusicFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
- LyricsSearchProvider.LocalEslrcFile => _localizer.GetLocalizedString("LyricsSearchProviderEslrcFile"),
- LyricsSearchProvider.LocalTtmlFile => _localizer.GetLocalizedString("LyricsSearchProviderTtmlFile"),
+ LyricsSearchProvider.LocalLrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
+ LyricsSearchProvider.LocalMusicFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
+ LyricsSearchProvider.LocalEslrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderEslrcFile"),
+ LyricsSearchProvider.LocalTtmlFile => _localizationService.GetLocalizedString("LyricsSearchProviderTtmlFile"),
_ => "N/A",
};
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
index f3a525d..1800dfb 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/MatchedLocalFilesPathToVisibilityConverter.cs
@@ -1,22 +1,23 @@
// 2025/6/23 by Zhe Fang
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Converter
{
public partial class MatchedLocalFilesPathToVisibilityConverter : IValueConverter
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is string path)
{
- if (path == _localizer.GetLocalizedString("MainPageNoLocalFilesMatched"))
+ if (path == _localizationService.GetLocalizedString("MainPageNoLocalFilesMatched"))
{
return Visibility.Collapsed;
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
index 8d8675e..33e44a7 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TranslationSearchProviderToDisplayNameConverter.cs
@@ -1,15 +1,16 @@
// 2025/6/23 by Zhe Fang
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Converter
{
public partial class TranslationSearchProviderToDisplayNameConverter : IValueConverter
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public object Convert(object value, Type targetType, object parameter, string language)
{
@@ -23,10 +24,10 @@ namespace BetterLyrics.WinUI3.Converter
TranslationSearchProvider.Kugou => "酷狗音乐",
TranslationSearchProvider.AmllTtmlDb => "amll-ttml-db",
TranslationSearchProvider.AppleMusic => "Apple Music",
- TranslationSearchProvider.LocalLrcFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
- TranslationSearchProvider.LocalMusicFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
- TranslationSearchProvider.LocalEslrcFile => _localizer.GetLocalizedString("LyricsSearchProviderEslrcFile"),
- TranslationSearchProvider.LocalTtmlFile => _localizer.GetLocalizedString("LyricsSearchProviderTtmlFile"),
+ TranslationSearchProvider.LocalLrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
+ TranslationSearchProvider.LocalMusicFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
+ TranslationSearchProvider.LocalEslrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderEslrcFile"),
+ TranslationSearchProvider.LocalTtmlFile => _localizationService.GetLocalizedString("LyricsSearchProviderTtmlFile"),
TranslationSearchProvider.LibreTranslate => "LibreTranslate",
_ => "N/A",
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TransliterationSearchProviderToDisplayNameConverter.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TransliterationSearchProviderToDisplayNameConverter.cs
index 93d1f41..8459cd7 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TransliterationSearchProviderToDisplayNameConverter.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Converter/TransliterationSearchProviderToDisplayNameConverter.cs
@@ -1,13 +1,14 @@
using BetterLyrics.WinUI3.Enums;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Converter
{
public partial class TransliterationSearchProviderToDisplayNameConverter : IValueConverter
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public object Convert(object value, Type targetType, object parameter, string language)
{
@@ -21,10 +22,10 @@ namespace BetterLyrics.WinUI3.Converter
TransliterationSearchProvider.Kugou => "酷狗音乐",
TransliterationSearchProvider.AmllTtmlDb => "amll-ttml-db",
TransliterationSearchProvider.AppleMusic => "Apple Music",
- TransliterationSearchProvider.LocalLrcFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
- TransliterationSearchProvider.LocalMusicFile => _localizer.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
- TransliterationSearchProvider.LocalEslrcFile => _localizer.GetLocalizedString("LyricsSearchProviderEslrcFile"),
- TransliterationSearchProvider.LocalTtmlFile => _localizer.GetLocalizedString("LyricsSearchProviderTtmlFile"),
+ TransliterationSearchProvider.LocalLrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalLrcFile"),
+ TransliterationSearchProvider.LocalMusicFile => _localizationService.GetLocalizedString("LyricsSearchProviderLocalMusicFile"),
+ TransliterationSearchProvider.LocalEslrcFile => _localizationService.GetLocalizedString("LyricsSearchProviderEslrcFile"),
+ TransliterationSearchProvider.LocalTtmlFile => _localizationService.GetLocalizedString("LyricsSearchProviderTtmlFile"),
TransliterationSearchProvider.BetterLyrics => "BetterLyrics",
TransliterationSearchProvider.CutletDocker => "cutlet-docker",
_ => "N/A",
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/LyricsWindowStatusExtensions.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/LyricsWindowStatusExtensions.cs
index 3f4f6a5..0c4d4a1 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/LyricsWindowStatusExtensions.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/LyricsWindowStatusExtensions.cs
@@ -2,24 +2,24 @@
using BetterLyrics.WinUI3.Hooks;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
-
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Views;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Xaml;
using Windows.Foundation;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Extensions
{
public static class LyricsWindowStatusExtensions
{
- private static readonly ILocalizer _localizer = Localizer.Get();
+ private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public static LyricsWindowStatus DesktopMode(Window? window = null)
{
window ??= WindowHook.GetWindow();
return new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("DesktopMode"),
+ Name = _localizationService.GetLocalizedString("DesktopMode"),
LyricsDisplayType = LyricsDisplayType.LyricsOnly,
WindowBounds = new Rect(100, 100, 600, 250),
IsLocked = true,
@@ -44,7 +44,7 @@ namespace BetterLyrics.WinUI3.Extensions
window ??= WindowHook.GetWindow();
var status = new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("DockedMode"),
+ Name = _localizationService.GetLocalizedString("DockedMode"),
IsWorkArea = true,
IsAlwaysOnTop = true,
IsAlwaysOnTopPolling = true,
@@ -71,7 +71,7 @@ namespace BetterLyrics.WinUI3.Extensions
window ??= WindowHook.GetWindow();
var status = new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("FullscreenMode"),
+ Name = _localizationService.GetLocalizedString("FullscreenMode"),
LyricsLayoutOrientation = LyricsLayoutOrientation.Vertical,
LyricsStyleSettings = new LyricsStyleSettings
{
@@ -93,7 +93,7 @@ namespace BetterLyrics.WinUI3.Extensions
window ??= WindowHook.GetWindow();
return new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("StandardMode"),
+ Name = _localizationService.GetLocalizedString("StandardMode"),
};
}
@@ -102,7 +102,7 @@ namespace BetterLyrics.WinUI3.Extensions
window ??= WindowHook.GetWindow();
return new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("NarrowMode"),
+ Name = _localizationService.GetLocalizedString("NarrowMode"),
WindowBounds = new Rect(100, 100, 400, 800),
LyricsLayoutOrientation = LyricsLayoutOrientation.Vertical,
};
@@ -113,7 +113,7 @@ namespace BetterLyrics.WinUI3.Extensions
window ??= WindowHook.GetWindow();
return new LyricsWindowStatus(window)
{
- Name = _localizer.GetLocalizedString("TaskbarMode"),
+ Name = _localizationService.GetLocalizedString("TaskbarMode"),
LyricsDisplayType = LyricsDisplayType.LyricsOnly,
IsPinToTaskbar = true,
IsLocked = true,
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/WindowExtensions.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/WindowExtensions.cs
index c1fb308..4abaf92 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/WindowExtensions.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Extensions/WindowExtensions.cs
@@ -1,14 +1,15 @@
using BetterLyrics.WinUI3.Enums;
using BetterLyrics.WinUI3.Helper;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Extensions
{
public static class WindowExtensions
{
- private static readonly ILocalizer _localizer = Localizer.Get();
+ private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
extension(Window window)
{
@@ -17,7 +18,7 @@ namespace BetterLyrics.WinUI3.Extensions
TitleBarHeightOption titleBarHeightOption = TitleBarHeightOption.Standard,
BackdropType backdropType = BackdropType.DesktopAcrylic)
{
- window.Title = _localizer.GetLocalizedString(titleKey);
+ window.Title = _localizationService.GetLocalizedString(titleKey);
window.AppWindow.TitleBar.PreferredTheme = TitleBarTheme.UseDefaultAppMode;
window.AppWindow.SetIcons();
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
index dda4d15..8b5e5fb 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/LanguageHelper.cs
@@ -1,10 +1,8 @@
using BetterLyrics.WinUI3.Models;
using NTextCat;
using System.Collections.Generic;
-using System.Globalization;
using System.Linq;
using Windows.Globalization;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Helper
{
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
index d2677dd..b7fc0c9 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/PhoneticHelper.cs
@@ -1,11 +1,12 @@
-using System;
-using WinUI3Localizer;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using System;
namespace BetterLyrics.WinUI3.Helper
{
public static class PhoneticHelper
{
- private static readonly ILocalizer _localizer = Localizer.Get();
+ private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public const string PinyinCode = "zh-cmn-pinyin";
public const string JyutpingCode = "zh-yue-jyutping";
@@ -21,11 +22,11 @@ namespace BetterLyrics.WinUI3.Helper
switch (code)
{
case PinyinCode:
- return _localizer.GetLocalizedString("Pinyin");
+ return _localizationService.GetLocalizedString("Pinyin");
case JyutpingCode:
- return _localizer.GetLocalizedString("Jyutping");
+ return _localizationService.GetLocalizedString("Jyutping");
case RomanCode:
- return _localizer.GetLocalizedString("Romaji");
+ return _localizationService.GetLocalizedString("Romaji");
default:
throw new ArgumentOutOfRangeException(nameof(code));
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ToastHelper.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ToastHelper.cs
index 5d37675..4ccbf63 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ToastHelper.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Helper/ToastHelper.cs
@@ -1,18 +1,19 @@
-using Microsoft.UI.Xaml.Controls;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
+using Microsoft.UI.Xaml.Controls;
using Microsoft.Windows.AppNotifications;
using Microsoft.Windows.AppNotifications.Builder;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Helper
{
public class ToastHelper
{
- private static readonly ILocalizer _localizer = Localizer.Get();
+ private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public static void ShowToast(string localizedTitleKey, string? description, InfoBarSeverity severity)
{
AppNotification notification = new AppNotificationBuilder()
- .AddText(_localizer.GetLocalizedString(localizedTitleKey))
+ .AddText(_localizationService.GetLocalizedString(localizedTitleKey))
.AddText(description)
.BuildNotification();
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
index d9722fa..8b6abf8 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Models/LyricsData.cs
@@ -1,14 +1,15 @@
using BetterLyrics.WinUI3.Helper;
+using BetterLyrics.WinUI3.Services.LocalizationService;
+using CommunityToolkit.Mvvm.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Models
{
public class LyricsData
{
- private static readonly ILocalizer _localizer = Localizer.Get();
+ private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService();
public List LyricsLines { get; set; } = [];
public string? LanguageCode
@@ -112,7 +113,7 @@ namespace BetterLyrics.WinUI3.Models
{
StartMs = 0,
EndMs = (int)TimeSpan.FromMinutes(99).TotalMilliseconds,
- OriginalText = _localizer.GetLocalizedString("LyricsNotFound"),
+ OriginalText = _localizationService.GetLocalizedString("LyricsNotFound"),
}]);
}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
index 635efcb..287646d 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LastFMService/LastFMService.cs
@@ -2,7 +2,7 @@
using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Hooks;
using BetterLyrics.WinUI3.Models;
-
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Views;
using Hqub.Lastfm;
@@ -10,14 +10,13 @@ using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;
using Windows.System;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Services.LastFMService
{
public partial class LastFMService : ILastFMService
{
private readonly ISettingsService _settingsService;
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService;
private readonly LastfmClient _client;
@@ -28,8 +27,9 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
public bool IsAuthenticated { get; private set; }
- public LastFMService(ISettingsService settingsService)
+ public LastFMService(ISettingsService settingsService, ILocalizationService localizationService)
{
+ _localizationService = localizationService;
_settingsService = settingsService;
_client = new LastfmClient(Constants.LastFM.ApiKey, Constants.LastFM.SharedSecret);
@@ -68,10 +68,10 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
var dialog = new ContentDialog
{
- Title = _localizer.GetLocalizedString("LastFMRequestAuthTitle") ?? "",
- Content = _localizer.GetLocalizedString("LastFMRequestAuthDesc") ?? "",
- PrimaryButtonText = _localizer.GetLocalizedString("LastFMRequestAuthConfirm") ?? "",
- CloseButtonText = _localizer.GetLocalizedString("Cancel") ?? "",
+ Title = _localizationService.GetLocalizedString("LastFMRequestAuthTitle") ?? "",
+ Content = _localizationService.GetLocalizedString("LastFMRequestAuthDesc") ?? "",
+ PrimaryButtonText = _localizationService.GetLocalizedString("LastFMRequestAuthConfirm") ?? "",
+ CloseButtonText = _localizationService.GetLocalizedString("Cancel") ?? "",
DefaultButton = ContentDialogButton.Close,
XamlRoot = dialogXamlRoot,
};
@@ -95,10 +95,10 @@ namespace BetterLyrics.WinUI3.Services.LastFMService
var dialog = new ContentDialog
{
- Title = _localizer.GetLocalizedString("LastFMRequestUnAuthTitle") ?? "",
- Content = _localizer.GetLocalizedString("LastFMRequestUnAuthDesc") ?? "",
- PrimaryButtonText = _localizer.GetLocalizedString("LastFMRequestUnAuthConfirm") ?? "",
- CloseButtonText = _localizer.GetLocalizedString("Cancel") ?? "",
+ Title = _localizationService.GetLocalizedString("LastFMRequestUnAuthTitle") ?? "",
+ Content = _localizationService.GetLocalizedString("LastFMRequestUnAuthDesc") ?? "",
+ PrimaryButtonText = _localizationService.GetLocalizedString("LastFMRequestUnAuthConfirm") ?? "",
+ CloseButtonText = _localizationService.GetLocalizedString("Cancel") ?? "",
DefaultButton = ContentDialogButton.Close,
XamlRoot = dialogXamlRoot,
};
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/ILocalizationService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/ILocalizationService.cs
new file mode 100644
index 0000000..d4d959e
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/ILocalizationService.cs
@@ -0,0 +1,7 @@
+namespace BetterLyrics.WinUI3.Services.LocalizationService
+{
+ public interface ILocalizationService
+ {
+ string GetLocalizedString(string id);
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/LocalizationService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/LocalizationService.cs
new file mode 100644
index 0000000..4bc1de2
--- /dev/null
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/LocalizationService/LocalizationService.cs
@@ -0,0 +1,14 @@
+using Microsoft.Windows.ApplicationModel.Resources;
+
+namespace BetterLyrics.WinUI3.Services.LocalizationService
+{
+ public class LocalizationService : ILocalizationService
+ {
+ private readonly ResourceLoader _resourceLoader = new();
+
+ public string GetLocalizedString(string id)
+ {
+ return _resourceLoader.GetString(id);
+ }
+ }
+}
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/SettingsService/SettingsService.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/SettingsService/SettingsService.cs
index f679110..b83e947 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/SettingsService/SettingsService.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Services/SettingsService/SettingsService.cs
@@ -7,29 +7,28 @@ using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Serialization;
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.ViewModels;
using CommunityToolkit.WinUI;
using Microsoft.UI.Dispatching;
-using Microsoft.UI.Xaml;
using System;
-using System.Globalization;
using System.IO;
using System.Linq;
using Windows.Globalization;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.Services.SettingsService
{
// 新建一个 AppSettings 类
public partial class SettingsService : BaseViewModel, ISettingsService
{
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService;
private readonly DispatcherQueueTimer _writeAppSettingsTimer;
public AppSettings AppSettings { get; set; }
- public SettingsService()
+ public SettingsService(ILocalizationService localizationService)
{
+ _localizationService = localizationService;
_writeAppSettingsTimer = _dispatcherQueue.CreateTimer();
AppSettings = ReadAppSettings();
@@ -129,7 +128,8 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
public void UpdateLanguage()
{
var langCode = AppSettings.GeneralSettings.LanguageCode;
- _localizer.SetLanguage(LanguageHelper.ParseLanguageCode(langCode));
+ var parsedLangCode = LanguageHelper.ParseLanguageCode(langCode);
+ ApplicationLanguages.PrimaryLanguageOverride = parsedLangCode;
}
///
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
index 952d16e..a533a57 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MediaSettingsControlViewModel.cs
@@ -3,7 +3,7 @@ using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Hooks;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
-
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
@@ -14,20 +14,20 @@ using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.ViewModels
{
public partial class MediaSettingsControlViewModel : BaseViewModel
{
private readonly ISettingsService _settingsService;
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService;
[ObservableProperty]
public partial AppSettings AppSettings { get; set; }
- public MediaSettingsControlViewModel(ISettingsService settingsService)
+ public MediaSettingsControlViewModel(ISettingsService settingsService, ILocalizationService localizationService)
{
+ _localizationService = localizationService;
_settingsService = settingsService;
AppSettings = _settingsService.AppSettings;
}
@@ -81,8 +81,8 @@ namespace BetterLyrics.WinUI3.ViewModels
XamlRoot = WindowHook.GetWindow()?.Content.XamlRoot,
Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style,
Title = protocolType,
- PrimaryButtonText = _localizer.GetLocalizedString("Add"),
- CloseButtonText = _localizer.GetLocalizedString("Cancel"),
+ PrimaryButtonText = _localizationService.GetLocalizedString("Add"),
+ CloseButtonText = _localizationService.GetLocalizedString("Cancel"),
DefaultButton = ContentDialogButton.Primary,
Content = new RemoteServerConfigControl(protocolType)
};
@@ -116,7 +116,7 @@ namespace BetterLyrics.WinUI3.ViewModels
}
else
{
- ShowErrorTip(configControl, _localizer.GetLocalizedString("SettingsPageServerTestFailedInfo"));
+ ShowErrorTip(configControl, _localizationService.GetLocalizedString("SettingsPageServerTestFailedInfo"));
}
}
catch (Exception ex)
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs
index 220ca22..6a0d390 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/ViewModels/MusicGalleryPageViewModel.cs
@@ -6,7 +6,7 @@ using BetterLyrics.WinUI3.Helper;
using BetterLyrics.WinUI3.Models;
using BetterLyrics.WinUI3.Models.Settings;
using BetterLyrics.WinUI3.Services.LibWatcherService;
-
+using BetterLyrics.WinUI3.Services.LocalizationService;
using BetterLyrics.WinUI3.Services.SettingsService;
using BetterLyrics.WinUI3.Views;
using CommunityToolkit.Mvvm.ComponentModel;
@@ -25,7 +25,6 @@ using Windows.Media;
using Windows.Media.Core;
using Windows.Media.Playback;
using Windows.Storage;
-using WinUI3Localizer;
namespace BetterLyrics.WinUI3.ViewModels
{
@@ -33,7 +32,7 @@ namespace BetterLyrics.WinUI3.ViewModels
{
private readonly ILibWatcherService _libWatcherService;
private readonly ISettingsService _settingsService;
- private readonly ILocalizer _localizer = Localizer.Get();
+ private readonly ILocalizationService _localizationService;
private readonly MediaPlayer _mediaPlayer = new();
private readonly MediaTimelineController _timelineController = new();
@@ -94,8 +93,9 @@ namespace BetterLyrics.WinUI3.ViewModels
[ObservableProperty]
public partial string SongSearchQuery { get; set; } = string.Empty;
- public MusicGalleryPageViewModel(ISettingsService settingsService, ILibWatcherService libWatcherService)
+ public MusicGalleryPageViewModel(ISettingsService settingsService, ILibWatcherService libWatcherService, ILocalizationService localizationService)
{
+ _localizationService = localizationService;
_refreshSongsTimer = _dispatcherQueue.CreateTimer();
_settingsService = settingsService;
@@ -104,7 +104,7 @@ namespace BetterLyrics.WinUI3.ViewModels
TrackPlayingQueue = [.. AppSettings.MusicGallerySettings.PlayQueuePaths.Select(x => new PlayQueueItem(new ExtendedTrack(x)))];
TrackPlayingQueue.CollectionChanged += TrackPlayingQueue_CollectionChanged;
- SongsTabInfoList.Add(new SongsTabInfo(_localizer.GetLocalizedString("MusicGalleryPageAllSongs"), "\uE8A9", false, false, CommonSongProperty.Title, string.Empty));
+ SongsTabInfoList.Add(new SongsTabInfo(_localizationService.GetLocalizedString("MusicGalleryPageAllSongs"), "\uE8A9", false, false, CommonSongProperty.Title, string.Empty));
RefreshSongs();
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml
index 601129b..32a832f 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml
@@ -10,7 +10,6 @@
xmlns:ext="using:BetterLyrics.WinUI3.Extensions"
xmlns:helper="using:BetterLyrics.WinUI3.Helper"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
xmlns:local="using:BetterLyrics.WinUI3.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -69,21 +68,21 @@
Grid.Row="1"
Padding="12"
Spacing="6">
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
@@ -108,7 +107,7 @@
FontFamily="{StaticResource IconFontFamily}"
FontSize="16"
Glyph="" />
-
+
@@ -136,7 +135,7 @@
FontFamily="{StaticResource IconFontFamily}"
FontSize="16"
Glyph="" />
-
+
@@ -157,7 +156,7 @@
FontFamily="{StaticResource IconFontFamily}"
FontSize="16"
Glyph="" />
-
+
@@ -218,8 +217,8 @@
Visibility="{x:Bind IsClosable, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
-
-
+
+
@@ -283,9 +282,9 @@
@@ -320,17 +319,17 @@
Spacing="6">
-
-
-
-
+
+
+
+
@@ -347,12 +346,12 @@
SelectionMode="Multiple">
-
-
-
+
+
+
@@ -508,8 +507,8 @@
Spacing="12">
@@ -533,9 +532,9 @@
-
+
@@ -570,9 +569,9 @@
-
-
-
+
+
+
@@ -622,7 +621,7 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
@@ -636,7 +635,7 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
@@ -668,7 +667,7 @@
Glyph=}"
Style="{StaticResource GhostButtonStyle}">
-
+
@@ -698,8 +697,8 @@
Spacing="12">
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml.cs b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml.cs
index f675063..dd96bbb 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml.cs
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/MusicGalleryPage.xaml.cs
@@ -14,7 +14,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using WinUI3Localizer;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -26,8 +25,6 @@ namespace BetterLyrics.WinUI3.Views
///
public sealed partial class MusicGalleryPage : Page
{
- private readonly ILocalizer _localizer = Localizer.Get();
-
public MusicGalleryPageViewModel ViewModel => (MusicGalleryPageViewModel)DataContext;
public MusicGalleryPage()
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingPage.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingPage.xaml
index ac1afe6..704a8d4 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingPage.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingPage.xaml
@@ -11,7 +11,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
@@ -80,11 +79,11 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingWindow.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingWindow.xaml
index fc6ce63..1aee783 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingWindow.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/NowPlayingWindow.xaml
@@ -7,7 +7,6 @@
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:media="using:CommunityToolkit.WinUI.Media"
@@ -57,7 +56,7 @@
FontSize="{x:Bind ViewModel.TitleBarFontSize, Mode=OneWay}"
Glyph="" />
-
+
@@ -71,7 +70,7 @@
FontSize="{x:Bind ViewModel.TitleBarFontSize, Mode=OneWay}"
Glyph="" />
-
+
@@ -82,7 +81,7 @@
FontSize="{x:Bind ViewModel.TitleBarFontSize, Mode=OneWay}"
Glyph="" />
-
+
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsPage.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsPage.xaml
index 3c84b14..07fb90b 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsPage.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsPage.xaml
@@ -8,7 +8,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dev="using:DevWinUI"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:BetterLyrics.WinUI3.Models"
@@ -27,32 +26,32 @@
diff --git a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsWindow.xaml b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsWindow.xaml
index a22a59e..ad920b1 100644
--- a/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsWindow.xaml
+++ b/BetterLyrics.WinUI3/BetterLyrics.WinUI3/Views/SettingsWindow.xaml
@@ -4,7 +4,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:l="using:WinUI3Localizer"
xmlns:local="using:BetterLyrics.WinUI3.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:BetterLyrics.WinUI3.Controls"
@@ -22,7 +21,7 @@
FontSize="12"
Glyph="" />
-
+
@@ -33,7 +32,7 @@
Glyph=}"
Style="{StaticResource TitleBarButtonStyle}">
-
+