diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Annotation/LocalizationKeyAttribute.cs b/src/Snap.Hutao/Snap.Hutao/Core/Annotation/LocalizationKeyAttribute.cs new file mode 100644 index 00000000..d43b7f82 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Core/Annotation/LocalizationKeyAttribute.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Snap.Hutao.Core.Annotation; + +/// +/// 本地化键 +/// +internal class LocalizationKeyAttribute : Attribute +{ + /// + /// 指定本地化键 + /// + /// 键 + public LocalizationKeyAttribute(string key) + { + Key = key; + } + + /// + /// 键 + /// + public string Key { get; } +} diff --git a/src/Snap.Hutao/Snap.Hutao/Extension/EnumExtension.cs b/src/Snap.Hutao/Snap.Hutao/Extension/EnumExtension.cs index ec333e32..6f7df336 100644 --- a/src/Snap.Hutao/Snap.Hutao/Extension/EnumExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Extension/EnumExtension.cs @@ -1,6 +1,7 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. +using Snap.Hutao.Core.Annotation; using System.Reflection; namespace Snap.Hutao.Extension; @@ -39,4 +40,25 @@ public static class EnumExtension DescriptionAttribute? attr = field?.GetCustomAttribute(); return attr?.Description; } + + /// + /// 获取本地化的描述 + /// + /// 枚举的类型 + /// 枚举值 + /// 本地化的描述 + public static string GetLocalizedDescription(this TEnum @enum) + where TEnum : struct, Enum + { + string enumName = Enum.GetName(@enum)!; + FieldInfo? field = @enum.GetType().GetField(enumName); + LocalizationKeyAttribute? attr = field?.GetCustomAttribute(); + string? result = null; + if (attr != null) + { + result = SH.ResourceManager.GetString(attr.Key); + } + + return result ?? enumName; + } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Binding/LaunchGame/LaunchScheme.cs b/src/Snap.Hutao/Snap.Hutao/Model/Binding/LaunchGame/LaunchScheme.cs index 9b3b0a34..c0b3d5ca 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Binding/LaunchGame/LaunchScheme.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Binding/LaunchGame/LaunchScheme.cs @@ -15,9 +15,9 @@ public class LaunchScheme /// public static readonly ImmutableList KnownSchemes = new List() { - new LaunchScheme("官方服", "eYd89JmJ", "18", "1", "1"), - new LaunchScheme("渠道服", "KAtdSsoQ", "17", "14", "0"), - new LaunchScheme("国际服", "gcStgarh", "10", "1", "0"), + new LaunchScheme(SH.ModelBindingLaunchGameLaunchSchemeChinese, "eYd89JmJ", "18", "1", "1"), + new LaunchScheme(SH.ModelBindingLaunchGameLaunchSchemeBilibili, "KAtdSsoQ", "17", "14", "0"), + new LaunchScheme(SH.ModelBindingLaunchGameLaunchSchemeOversea, "gcStgarh", "10", "1", "0"), }.ToImmutableList(); /// diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs index 955bd0c2..1512b802 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.Designer.cs @@ -267,6 +267,33 @@ namespace Snap.Hutao.Resource.Localization { } } + /// + /// 查找类似 渠道服 的本地化字符串。 + /// + internal static string ModelBindingLaunchGameLaunchSchemeBilibili { + get { + return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeBilibili", resourceCulture); + } + } + + /// + /// 查找类似 官方服 的本地化字符串。 + /// + internal static string ModelBindingLaunchGameLaunchSchemeChinese { + get { + return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeChinese", resourceCulture); + } + } + + /// + /// 查找类似 国际服 的本地化字符串。 + /// + internal static string ModelBindingLaunchGameLaunchSchemeOversea { + get { + return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeOversea", resourceCulture); + } + } + /// /// 查找类似 {0:f2} 抽 的本地化字符串。 /// @@ -1050,6 +1077,24 @@ namespace Snap.Hutao.Resource.Localization { } } + /// + /// 查找类似 祈愿记录Url已失效,请重新获取 的本地化字符串。 + /// + internal static string ViewDialogGachaLogRefreshProgressAuthkeyTimeout { + get { + return ResourceManager.GetString("ViewDialogGachaLogRefreshProgressAuthkeyTimeout", resourceCulture); + } + } + + /// + /// 查找类似 正在获取 {0} 的本地化字符串。 + /// + internal static string ViewDialogGachaLogRefreshProgressDescription { + get { + return ResourceManager.GetString("ViewDialogGachaLogRefreshProgressDescription", resourceCulture); + } + } + /// /// 查找类似 获取祈愿物品中 的本地化字符串。 /// @@ -1177,7 +1222,7 @@ namespace Snap.Hutao.Resource.Localization { } /// - /// 查找类似 转换客户端 的本地化字符串。 + /// 查找类似 正在转换客户端 的本地化字符串。 /// internal static string ViewDialogLaunchGamePackageConvertTitle { get { @@ -3642,6 +3687,51 @@ namespace Snap.Hutao.Resource.Localization { } } + /// + /// 查找类似 角色活动祈愿 的本地化字符串。 + /// + internal static string WebGachaConfigTypeAvatarEventWish { + get { + return ResourceManager.GetString("WebGachaConfigTypeAvatarEventWish", resourceCulture); + } + } + + /// + /// 查找类似 角色活动祈愿-2 的本地化字符串。 + /// + internal static string WebGachaConfigTypeAvatarEventWish2 { + get { + return ResourceManager.GetString("WebGachaConfigTypeAvatarEventWish2", resourceCulture); + } + } + + /// + /// 查找类似 新手祈愿 的本地化字符串。 + /// + internal static string WebGachaConfigTypeNoviceWish { + get { + return ResourceManager.GetString("WebGachaConfigTypeNoviceWish", resourceCulture); + } + } + + /// + /// 查找类似 常驻祈愿 的本地化字符串。 + /// + internal static string WebGachaConfigTypePermanentWish { + get { + return ResourceManager.GetString("WebGachaConfigTypePermanentWish", resourceCulture); + } + } + + /// + /// 查找类似 武器活动祈愿 的本地化字符串。 + /// + internal static string WebGachaConfigTypeWeaponEventWish { + get { + return ResourceManager.GetString("WebGachaConfigTypeWeaponEventWish", resourceCulture); + } + } + /// /// 查找类似 状态:{0} | 信息:{1} 的本地化字符串。 /// diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx index 6a733c73..01c97771 100644 --- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx +++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx @@ -186,6 +186,15 @@ 第 {0} 层 + + 渠道服 + + + 官方服 + + + 国际服 + {0:f2} 抽 @@ -447,6 +456,12 @@ 导入祈愿记录 + + 祈愿记录Url已失效,请重新获取 + + + 正在获取 {0} + 获取祈愿物品中 @@ -490,7 +505,7 @@ 转换可能需要花费一段时间,请勿关闭胡桃 - 转换客户端 + 正在转换客户端 立即前往 @@ -1311,6 +1326,21 @@ 武器资料 + + 角色活动祈愿 + + + 角色活动祈愿-2 + + + 新手祈愿 + + + 常驻祈愿 + + + 武器活动祈愿 + 状态:{0} | 信息:{1} diff --git a/src/Snap.Hutao/Snap.Hutao/View/Dialog/GachaLogRefreshProgressDialog.xaml.cs b/src/Snap.Hutao/Snap.Hutao/View/Dialog/GachaLogRefreshProgressDialog.xaml.cs index 0926fb18..8cc8d18e 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Dialog/GachaLogRefreshProgressDialog.xaml.cs +++ b/src/Snap.Hutao/Snap.Hutao/View/Dialog/GachaLogRefreshProgressDialog.xaml.cs @@ -8,6 +8,7 @@ using Snap.Hutao.Extension; using Snap.Hutao.Model.Binding.Gacha.Abstraction; using Snap.Hutao.Service.GachaLog; using Snap.Hutao.View.Control; +using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo; namespace Snap.Hutao.View.Dialog; @@ -45,8 +46,8 @@ public sealed partial class GachaLogRefreshProgressDialog : ContentDialog { State = state; GachaItemsPresenter.Header = state.AuthKeyTimeout - ? "祈愿记录Url已失效,请重新获取" - : (object)$"正在获取 {state.ConfigType.GetDescription()}"; + ? SH.ViewDialogGachaLogRefreshProgressAuthkeyTimeout + : string.Format(SH.ViewDialogGachaLogRefreshProgressDescription, state.ConfigType.GetLocalizedDescription()); // Binding not working here. GachaItemsPresenter.Items.Clear(); diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaConfigType.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaConfigType.cs index f2f05a8d..f8bc7878 100644 --- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaConfigType.cs +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Hk4e/Event/GachaInfo/GachaConfigType.cs @@ -1,6 +1,8 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. +using Snap.Hutao.Core.Annotation; + namespace Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo; /// @@ -12,29 +14,34 @@ public enum GachaConfigType /// 新手池 /// [Description("新手祈愿")] + [LocalizationKey("WebGachaConfigTypeNoviceWish")] NoviceWish = 100, /// /// 常驻池 /// [Description("常驻祈愿")] + [LocalizationKey("WebGachaConfigTypePermanentWish")] PermanentWish = 200, /// /// 角色1池 /// [Description("角色活动祈愿")] + [LocalizationKey("WebGachaConfigTypeAvatarEventWish")] AvatarEventWish = 301, /// /// 武器池 /// [Description("武器活动祈愿")] + [LocalizationKey("WebGachaConfigTypeWeaponEventWish")] WeaponEventWish = 302, /// /// 角色2池 /// [Description("角色活动祈愿-2")] + [LocalizationKey("WebGachaConfigTypeAvatarEventWish2")] AvatarEventWish2 = 400, } \ No newline at end of file