Add support for zh-hant
Refactor to make language specifiable in appsettings
This commit is contained in:
parent
16cc17246f
commit
ccd3b22b41
35
TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx
Normal file
35
TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx
Normal file
@ -0,0 +1,35 @@
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="dashboard" xml:space="preserve">
|
||||
<value>Dashboard</value>
|
||||
</data>
|
||||
<data name="users" xml:space="preserve">
|
||||
<value>Users</value>
|
||||
</data>
|
||||
<data name="edit profile" xml:space="preserve">
|
||||
<value>Edit Profile</value>
|
||||
</data>
|
||||
<data name="user" xml:space="preserve">
|
||||
<value>User</value>
|
||||
</data>
|
||||
<data name="view play data" xml:space="preserve">
|
||||
<value>View Play Data</value>
|
||||
</data>
|
||||
<data name="high scores" xml:space="preserve">
|
||||
<value>High Scores</value>
|
||||
</data>
|
||||
<data name="dani dojo" xml:space="preserve">
|
||||
<value>Dani Dojo</value>
|
||||
</data>
|
||||
</root>
|
8
TaikoWebUI/Settings/Language.cs
Normal file
8
TaikoWebUI/Settings/Language.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace TaikoWebUI.Settings;
|
||||
|
||||
public class Language
|
||||
{
|
||||
public string CultureCode { get; set; } = "en-US";
|
||||
|
||||
public string DisplayName { get; set; } = "English";
|
||||
}
|
@ -2,10 +2,11 @@
|
||||
|
||||
public class WebUiSettings
|
||||
{
|
||||
public bool LoginRequired { get; set; }
|
||||
public bool OnlyAdmin { get; set; }
|
||||
public int BoundAccessCodeUpperLimit { get; set; }
|
||||
public bool RegisterWithLastPlayTime { get; set; }
|
||||
public bool AllowUserDelete { get; set; }
|
||||
public bool AllowFreeProfileEditing { get; set; }
|
||||
public bool LoginRequired { get; set; }
|
||||
public bool OnlyAdmin { get; set; }
|
||||
public int BoundAccessCodeUpperLimit { get; set; }
|
||||
public bool RegisterWithLastPlayTime { get; set; }
|
||||
public bool AllowUserDelete { get; set; }
|
||||
public bool AllowFreeProfileEditing { get; set; }
|
||||
public Language[] SupportedLanguages { get; set; } = Array.Empty<Language>();
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
@using System.Globalization;
|
||||
@using Microsoft.Extensions.Options
|
||||
@using TaikoWebUI.Settings
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject IOptions<WebUiSettings> Settings
|
||||
|
||||
<MudMenu Icon="@Icons.Material.Filled.Language" Color="Color.Inherit">
|
||||
@foreach (var culture in SupportedCultures)
|
||||
@ -11,12 +14,21 @@
|
||||
|
||||
|
||||
@code{
|
||||
public readonly Dictionary<CultureInfo, string> SupportedCultures = new()
|
||||
public Dictionary<CultureInfo, string> SupportedCultures = new();
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
{ new CultureInfo("en-US"), "English" },
|
||||
{ new CultureInfo("zh-Hans"), "简体中文" },
|
||||
{ new CultureInfo("ja"), "日本語" },
|
||||
};
|
||||
base.OnInitialized();
|
||||
foreach (var language in Settings.Value.SupportedLanguages)
|
||||
{
|
||||
SupportedCultures.Add(new CultureInfo(language.CultureCode), language.DisplayName);
|
||||
}
|
||||
|
||||
if (SupportedCultures.Count == 0)
|
||||
{
|
||||
SupportedCultures.Add(new CultureInfo("en-US"), "English");
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestCultureChange(CultureInfo newCulture)
|
||||
{
|
||||
|
@ -87,6 +87,11 @@
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>LocalizationResource</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Localization\LocalizationResource.zh-Hant.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<CustomToolNamespace>LocalizationResource</CustomToolNamespace>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -5,6 +5,24 @@
|
||||
"BoundAccessCodeUpperLimit": "3",
|
||||
"RegisterWithLastPlayTime": "false",
|
||||
"AllowUserDelete": "true",
|
||||
"AllowFreeProfileEditing": "true"
|
||||
"AllowFreeProfileEditing": "true",
|
||||
"SupportedLanguages": [
|
||||
{
|
||||
"CultureCode": "en-US",
|
||||
"DisplayName": "English"
|
||||
},
|
||||
{
|
||||
"CultureCode": "zh-Hans",
|
||||
"DisplayName": "简体中文"
|
||||
},
|
||||
{
|
||||
"CultureCode": "zh-Hant",
|
||||
"DisplayName": "繁體中文"
|
||||
},
|
||||
{
|
||||
"CultureCode": "ja",
|
||||
"DisplayName": "日本語"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user