mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-12 15:57:28 +08:00
[+] i18n
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using AquaMai.Fix;
|
||||
using AquaMai.Helpers;
|
||||
using AquaMai.Resources;
|
||||
using AquaMai.Utils;
|
||||
using AquaMai.UX;
|
||||
using MelonLoader;
|
||||
using Tomlet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AquaMai
|
||||
{
|
||||
@@ -91,6 +95,22 @@ namespace AquaMai
|
||||
s.CopyTo(fs);
|
||||
}
|
||||
|
||||
private static void InitLocale()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(AppConfig.UX.Locale))
|
||||
{
|
||||
Locale.Culture = CultureInfo.GetCultureInfo(AppConfig.UX.Locale);
|
||||
return;
|
||||
}
|
||||
|
||||
Locale.Culture = Application.systemLanguage switch
|
||||
{
|
||||
SystemLanguage.Chinese or SystemLanguage.ChineseSimplified or SystemLanguage.ChineseTraditional => CultureInfo.GetCultureInfo("zh"),
|
||||
SystemLanguage.English => CultureInfo.GetCultureInfo("en"),
|
||||
_ => CultureInfo.InvariantCulture
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
// Prevent Chinese characters from being garbled
|
||||
@@ -119,6 +139,11 @@ namespace AquaMai
|
||||
AppConfig.UX.LoadAssetsPng = AppConfig.UX.LoadAssetsPng || AppConfig.UX.LoadJacketPng;
|
||||
AppConfig.UX.LoadJacketPng = false;
|
||||
|
||||
// Init locale with patching C# runtime
|
||||
// https://stackoverflow.com/questions/1952638/single-assembly-multi-language-windows-forms-deployment-ilmerge-and-satellite-a
|
||||
Patch(typeof(I18nSingleAssemblyHook));
|
||||
InitLocale();
|
||||
|
||||
// Fixes that does not have side effects
|
||||
// These don't need to be configurable
|
||||
|
||||
|
||||
Reference in New Issue
Block a user