mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
chores
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<Identity
|
||||
Name="37412.BetterLyrics"
|
||||
Publisher="CN=E1428B0E-DC1D-4EA4-ACB1-4556569D5BA9"
|
||||
Version="1.1.208.0" />
|
||||
Version="1.1.214.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="ca4a4830-fc19-40d9-b823-53e2bff3d816" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
@@ -28,15 +28,7 @@
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="de"/>
|
||||
<Resource Language="en"/>
|
||||
<Resource Language="es"/>
|
||||
<Resource Language="fr"/>
|
||||
<Resource Language="ja"/>
|
||||
<Resource Language="ko"/>
|
||||
<Resource Language="ru"/>
|
||||
<Resource Language="zh-Hans"/>
|
||||
<Resource Language="zh-Hant"/>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
|
||||
@@ -19,8 +19,10 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.Windows.ApplicationModel.Resources;
|
||||
using Microsoft.Windows.Globalization;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -67,10 +69,15 @@ namespace BetterLyrics.WinUI3
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs args)
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
var settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
|
||||
settingsService.UpdateLanguage();
|
||||
if (settingsService.AppSettings.GeneralSettings.LanguageCode == "")
|
||||
{
|
||||
settingsService.AppSettings.GeneralSettings.LanguageCode = CultureInfo.CurrentUICulture.Name;
|
||||
await Task.Delay(Constants.Time.DebounceTimeout * 2);
|
||||
WindowHook.RestartApp();
|
||||
}
|
||||
|
||||
WindowHook.OpenOrShowWindow<SystemTrayWindow>();
|
||||
|
||||
|
||||
@@ -387,41 +387,32 @@
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PRIResource Update="Strings\de\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\de-DE\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\en\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\en-US\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\es\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\es-ES\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\fr\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\fr-FR\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\ja\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\ja-JP\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\ko\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\ko-KR\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\ru\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<PRIResource Update="Strings\ru-RU\Resources.resw">
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\zh-Hans\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
<PRIResource Update="Strings\zh-Hant\Resources.resw">
|
||||
<Generator></Generator>
|
||||
<CopyToOutputDirectory></CopyToOutputDirectory>
|
||||
<Generator></Generator>
|
||||
</PRIResource>
|
||||
</ItemGroup>
|
||||
<!-- Publish Properties -->
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace BetterLyrics.WinUI3.Converter
|
||||
{
|
||||
if (value is string langCode)
|
||||
{
|
||||
langCode = LanguageHelper.ParseLanguageCode(langCode);
|
||||
return LanguageHelper.SupportedDisplayLanguages.FindIndex(x => x.LanguageCode == langCode);
|
||||
var found = LanguageHelper.SupportedDisplayLanguages.FindIndex(x => x.LanguageCode == langCode);
|
||||
return found == -1 ? 0 : found;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using BetterLyrics.WinUI3.Models;
|
||||
using BetterLyrics.WinUI3.Services.LocalizationService;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using NTextCat;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Windows.Globalization;
|
||||
|
||||
@@ -8,6 +12,7 @@ namespace BetterLyrics.WinUI3.Helper
|
||||
{
|
||||
public class LanguageHelper
|
||||
{
|
||||
private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService<ILocalizationService>();
|
||||
private static readonly RankedLanguageIdentifierFactory _factory = new();
|
||||
private static readonly RankedLanguageIdentifier _identifier;
|
||||
|
||||
@@ -89,13 +94,14 @@ namespace BetterLyrics.WinUI3.Helper
|
||||
|
||||
public static List<ExtendedLanguage> SupportedDisplayLanguages { get; set; } =
|
||||
[
|
||||
new ExtendedLanguage("de"),
|
||||
new ExtendedLanguage("en"),
|
||||
new ExtendedLanguage("es"),
|
||||
new ExtendedLanguage("fr"),
|
||||
new ExtendedLanguage("ja"),
|
||||
new ExtendedLanguage("ko"),
|
||||
new ExtendedLanguage("ru"),
|
||||
new ExtendedLanguage(CultureInfo.CurrentUICulture.Name, _localizationService.GetLocalizedString("SettingsPageSystemLanguage")),
|
||||
new ExtendedLanguage("de-DE"),
|
||||
new ExtendedLanguage("en-US"),
|
||||
new ExtendedLanguage("es-ES"),
|
||||
new ExtendedLanguage("fr-FR"),
|
||||
new ExtendedLanguage("ja-JP"),
|
||||
new ExtendedLanguage("ko-KR"),
|
||||
new ExtendedLanguage("ru-RU"),
|
||||
new ExtendedLanguage("zh-Hans"),
|
||||
new ExtendedLanguage("zh-Hant"),
|
||||
];
|
||||
@@ -143,39 +149,6 @@ namespace BetterLyrics.WinUI3.Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static string ParseLanguageCode(string? languageCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(languageCode))
|
||||
{
|
||||
languageCode = ApplicationLanguages.Languages.FirstOrDefault();
|
||||
}
|
||||
|
||||
if (languageCode == null)
|
||||
{
|
||||
return "en";
|
||||
}
|
||||
|
||||
var shortSysLangCode = languageCode.Substring(0, 2);
|
||||
var found = SupportedDisplayLanguages.FirstOrDefault(x => shortSysLangCode == x.LanguageCode.Substring(0, 2));
|
||||
if (found == null)
|
||||
{
|
||||
return "en";
|
||||
}
|
||||
else
|
||||
{
|
||||
var shortLangCodeFound = found.LanguageCode.Substring(0, 2);
|
||||
if (shortLangCodeFound == "zh")
|
||||
{
|
||||
// https://learn.microsoft.com/zh-cn/windows/apps/publish/publish-your-app/msix/app-package-requirements#supported-languages
|
||||
return languageCode is "zh-Hans" or "zh-CN" or "zh-Hans-CN" or "zh-SG" or "zh-Hans-SG" ? "zh-Hans" : "zh-Hant";
|
||||
}
|
||||
else
|
||||
{
|
||||
return shortLangCodeFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetOrderChar(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) return "#";
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
{
|
||||
AppSettings AppSettings { get; set; }
|
||||
|
||||
void UpdateLanguage();
|
||||
bool ImportSettings(string importPath);
|
||||
void ExportSettings(string exportPath);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ using BetterLyrics.WinUI3.ViewModels;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Globalization;
|
||||
|
||||
namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
@@ -21,14 +23,12 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
// 新建一个 AppSettings 类
|
||||
public partial class SettingsService : BaseViewModel, ISettingsService
|
||||
{
|
||||
private readonly ILocalizationService _localizationService;
|
||||
private readonly DispatcherQueueTimer _writeAppSettingsTimer;
|
||||
|
||||
public AppSettings AppSettings { get; set; }
|
||||
|
||||
public SettingsService(ILocalizationService localizationService)
|
||||
public SettingsService()
|
||||
{
|
||||
_localizationService = localizationService;
|
||||
_writeAppSettingsTimer = _dispatcherQueue.CreateTimer();
|
||||
|
||||
AppSettings = ReadAppSettings();
|
||||
@@ -117,7 +117,7 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(GeneralSettings.LanguageCode):
|
||||
UpdateLanguage();
|
||||
ApplicationLanguages.PrimaryLanguageOverride = AppSettings.GeneralSettings.LanguageCode;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -125,13 +125,6 @@ namespace BetterLyrics.WinUI3.Services.SettingsService
|
||||
WriteAppSettings();
|
||||
}
|
||||
|
||||
public void UpdateLanguage()
|
||||
{
|
||||
var langCode = AppSettings.GeneralSettings.LanguageCode;
|
||||
var parsedLangCode = LanguageHelper.ParseLanguageCode(langCode);
|
||||
ApplicationLanguages.PrimaryLanguageOverride = parsedLangCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export settings to specific folder
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user