diff --git a/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx b/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx new file mode 100644 index 0000000..0a76883 --- /dev/null +++ b/TaikoWebUI/Localization/LocalizationResource.zh-Hant.resx @@ -0,0 +1,35 @@ + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Dashboard + + + Users + + + Edit Profile + + + User + + + View Play Data + + + High Scores + + + Dani Dojo + + \ No newline at end of file diff --git a/TaikoWebUI/Settings/Language.cs b/TaikoWebUI/Settings/Language.cs new file mode 100644 index 0000000..874ec9c --- /dev/null +++ b/TaikoWebUI/Settings/Language.cs @@ -0,0 +1,8 @@ +namespace TaikoWebUI.Settings; + +public class Language +{ + public string CultureCode { get; set; } = "en-US"; + + public string DisplayName { get; set; } = "English"; +} \ No newline at end of file diff --git a/TaikoWebUI/Settings/WebUiSettings.cs b/TaikoWebUI/Settings/WebUiSettings.cs index 874688b..769df1b 100644 --- a/TaikoWebUI/Settings/WebUiSettings.cs +++ b/TaikoWebUI/Settings/WebUiSettings.cs @@ -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(); } \ No newline at end of file diff --git a/TaikoWebUI/Shared/ChooseLanguage.razor b/TaikoWebUI/Shared/ChooseLanguage.razor index f32281c..9f185b4 100644 --- a/TaikoWebUI/Shared/ChooseLanguage.razor +++ b/TaikoWebUI/Shared/ChooseLanguage.razor @@ -1,6 +1,9 @@ @using System.Globalization; +@using Microsoft.Extensions.Options +@using TaikoWebUI.Settings @inject NavigationManager NavigationManager @inject IJSRuntime JSRuntime +@inject IOptions Settings @foreach (var culture in SupportedCultures) @@ -11,12 +14,21 @@ @code{ - public readonly Dictionary SupportedCultures = new() + public Dictionary 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) { diff --git a/TaikoWebUI/TaikoWebUI.csproj b/TaikoWebUI/TaikoWebUI.csproj index 2bc060f..d3d18d9 100644 --- a/TaikoWebUI/TaikoWebUI.csproj +++ b/TaikoWebUI/TaikoWebUI.csproj @@ -87,6 +87,11 @@ ResXFileCodeGenerator LocalizationResource + + Designer + ResXFileCodeGenerator + LocalizationResource + diff --git a/TaikoWebUI/wwwroot/appsettings.json b/TaikoWebUI/wwwroot/appsettings.json index 5c6140f..f0b1931 100644 --- a/TaikoWebUI/wwwroot/appsettings.json +++ b/TaikoWebUI/wwwroot/appsettings.json @@ -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": "日本語" + } + ] } } \ No newline at end of file