add more globalization strings

This commit is contained in:
DismissedLight
2023-02-07 15:36:50 +08:00
parent 1df22e5b75
commit 898d95bb1d
7 changed files with 184 additions and 7 deletions

View File

@@ -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;
/// <summary>
/// 本地化键
/// </summary>
internal class LocalizationKeyAttribute : Attribute
{
/// <summary>
/// 指定本地化键
/// </summary>
/// <param name="key">键</param>
public LocalizationKeyAttribute(string key)
{
Key = key;
}
/// <summary>
/// 键
/// </summary>
public string Key { get; }
}

View File

@@ -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<DescriptionAttribute>();
return attr?.Description;
}
/// <summary>
/// 获取本地化的描述
/// </summary>
/// <typeparam name="TEnum">枚举的类型</typeparam>
/// <param name="enum">枚举值</param>
/// <returns>本地化的描述</returns>
public static string GetLocalizedDescription<TEnum>(this TEnum @enum)
where TEnum : struct, Enum
{
string enumName = Enum.GetName(@enum)!;
FieldInfo? field = @enum.GetType().GetField(enumName);
LocalizationKeyAttribute? attr = field?.GetCustomAttribute<LocalizationKeyAttribute>();
string? result = null;
if (attr != null)
{
result = SH.ResourceManager.GetString(attr.Key);
}
return result ?? enumName;
}
}

View File

@@ -15,9 +15,9 @@ public class LaunchScheme
/// </summary>
public static readonly ImmutableList<LaunchScheme> KnownSchemes = new List<LaunchScheme>()
{
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();
/// <summary>

View File

@@ -267,6 +267,33 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 渠道服 的本地化字符串。
/// </summary>
internal static string ModelBindingLaunchGameLaunchSchemeBilibili {
get {
return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeBilibili", resourceCulture);
}
}
/// <summary>
/// 查找类似 官方服 的本地化字符串。
/// </summary>
internal static string ModelBindingLaunchGameLaunchSchemeChinese {
get {
return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeChinese", resourceCulture);
}
}
/// <summary>
/// 查找类似 国际服 的本地化字符串。
/// </summary>
internal static string ModelBindingLaunchGameLaunchSchemeOversea {
get {
return ResourceManager.GetString("ModelBindingLaunchGameLaunchSchemeOversea", resourceCulture);
}
}
/// <summary>
/// 查找类似 {0:f2} 抽 的本地化字符串。
/// </summary>
@@ -1050,6 +1077,24 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 祈愿记录Url已失效请重新获取 的本地化字符串。
/// </summary>
internal static string ViewDialogGachaLogRefreshProgressAuthkeyTimeout {
get {
return ResourceManager.GetString("ViewDialogGachaLogRefreshProgressAuthkeyTimeout", resourceCulture);
}
}
/// <summary>
/// 查找类似 正在获取 {0} 的本地化字符串。
/// </summary>
internal static string ViewDialogGachaLogRefreshProgressDescription {
get {
return ResourceManager.GetString("ViewDialogGachaLogRefreshProgressDescription", resourceCulture);
}
}
/// <summary>
/// 查找类似 获取祈愿物品中 的本地化字符串。
/// </summary>
@@ -1177,7 +1222,7 @@ namespace Snap.Hutao.Resource.Localization {
}
/// <summary>
/// 查找类似 转换客户端 的本地化字符串。
/// 查找类似 正在转换客户端 的本地化字符串。
/// </summary>
internal static string ViewDialogLaunchGamePackageConvertTitle {
get {
@@ -3642,6 +3687,51 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 角色活动祈愿 的本地化字符串。
/// </summary>
internal static string WebGachaConfigTypeAvatarEventWish {
get {
return ResourceManager.GetString("WebGachaConfigTypeAvatarEventWish", resourceCulture);
}
}
/// <summary>
/// 查找类似 角色活动祈愿-2 的本地化字符串。
/// </summary>
internal static string WebGachaConfigTypeAvatarEventWish2 {
get {
return ResourceManager.GetString("WebGachaConfigTypeAvatarEventWish2", resourceCulture);
}
}
/// <summary>
/// 查找类似 新手祈愿 的本地化字符串。
/// </summary>
internal static string WebGachaConfigTypeNoviceWish {
get {
return ResourceManager.GetString("WebGachaConfigTypeNoviceWish", resourceCulture);
}
}
/// <summary>
/// 查找类似 常驻祈愿 的本地化字符串。
/// </summary>
internal static string WebGachaConfigTypePermanentWish {
get {
return ResourceManager.GetString("WebGachaConfigTypePermanentWish", resourceCulture);
}
}
/// <summary>
/// 查找类似 武器活动祈愿 的本地化字符串。
/// </summary>
internal static string WebGachaConfigTypeWeaponEventWish {
get {
return ResourceManager.GetString("WebGachaConfigTypeWeaponEventWish", resourceCulture);
}
}
/// <summary>
/// 查找类似 状态:{0} | 信息:{1} 的本地化字符串。
/// </summary>

View File

@@ -186,6 +186,15 @@
<data name="ModelBindingHutaoComplexAvatarRankFloor" xml:space="preserve">
<value>第 {0} 层</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeBilibili" xml:space="preserve">
<value>渠道服</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeChinese" xml:space="preserve">
<value>官方服</value>
</data>
<data name="ModelBindingLaunchGameLaunchSchemeOversea" xml:space="preserve">
<value>国际服</value>
</data>
<data name="ModelBingGachaTypedWishSummaryAveragePullFormat" xml:space="preserve">
<value>{0:f2} 抽</value>
</data>
@@ -447,6 +456,12 @@
<data name="ViewDialogGachaLogImportTitle" xml:space="preserve">
<value>导入祈愿记录</value>
</data>
<data name="ViewDialogGachaLogRefreshProgressAuthkeyTimeout" xml:space="preserve">
<value>祈愿记录Url已失效请重新获取</value>
</data>
<data name="ViewDialogGachaLogRefreshProgressDescription" xml:space="preserve">
<value>正在获取 {0}</value>
</data>
<data name="ViewDialogGachaLogRefreshProgressTitle" xml:space="preserve">
<value>获取祈愿物品中</value>
</data>
@@ -490,7 +505,7 @@
<value>转换可能需要花费一段时间,请勿关闭胡桃</value>
</data>
<data name="ViewDialogLaunchGamePackageConvertTitle" xml:space="preserve">
<value>转换客户端</value>
<value>正在转换客户端</value>
</data>
<data name="ViewDialogUserDocumentAction" xml:space="preserve">
<value>立即前往</value>
@@ -1311,6 +1326,21 @@
<data name="ViewWikiWeaponHeader" xml:space="preserve">
<value>武器资料</value>
</data>
<data name="WebGachaConfigTypeAvatarEventWish" xml:space="preserve">
<value>角色活动祈愿</value>
</data>
<data name="WebGachaConfigTypeAvatarEventWish2" xml:space="preserve">
<value>角色活动祈愿-2</value>
</data>
<data name="WebGachaConfigTypeNoviceWish" xml:space="preserve">
<value>新手祈愿</value>
</data>
<data name="WebGachaConfigTypePermanentWish" xml:space="preserve">
<value>常驻祈愿</value>
</data>
<data name="WebGachaConfigTypeWeaponEventWish" xml:space="preserve">
<value>武器活动祈愿</value>
</data>
<data name="WebResponseFormat" xml:space="preserve">
<value>状态:{0} | 信息:{1}</value>
</data>

View File

@@ -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();

View File

@@ -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;
/// <summary>
@@ -12,29 +14,34 @@ public enum GachaConfigType
/// 新手池
/// </summary>
[Description("新手祈愿")]
[LocalizationKey("WebGachaConfigTypeNoviceWish")]
NoviceWish = 100,
/// <summary>
/// 常驻池
/// </summary>
[Description("常驻祈愿")]
[LocalizationKey("WebGachaConfigTypePermanentWish")]
PermanentWish = 200,
/// <summary>
/// 角色1池
/// </summary>
[Description("角色活动祈愿")]
[LocalizationKey("WebGachaConfigTypeAvatarEventWish")]
AvatarEventWish = 301,
/// <summary>
/// 武器池
/// </summary>
[Description("武器活动祈愿")]
[LocalizationKey("WebGachaConfigTypeWeaponEventWish")]
WeaponEventWish = 302,
/// <summary>
/// 角色2池
/// </summary>
[Description("角色活动祈愿-2")]
[LocalizationKey("WebGachaConfigTypeAvatarEventWish2")]
AvatarEventWish2 = 400,
}