SHA256
Add Auto Localization Initialization
This commit is contained in:
2 files changed
+8
-2
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -33,6 +32,11 @@ internal static class LocalizationManager
|
|||||||
|
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
|
|
||||||
|
static LocalizationManager()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the localization system and loads embedded language dictionaries.
|
/// Initializes the localization system and loads embedded language dictionaries.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -115,7 +119,7 @@ internal static class LocalizationManager
|
|||||||
localeCode = FallbackLocaleCode;
|
localeCode = FallbackLocaleCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isChanged = (language != CurrentLanguage) || (localeCode != CurrentLocaleCode);
|
var isChanged = language != CurrentLanguage || localeCode != CurrentLocaleCode;
|
||||||
|
|
||||||
CurrentLanguage = language;
|
CurrentLanguage = language;
|
||||||
CurrentLocaleCode = localeCode;
|
CurrentLocaleCode = localeCode;
|
||||||
@@ -140,6 +144,7 @@ internal static class LocalizationManager
|
|||||||
public static string Get(string key)
|
public static string Get(string key)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key)) return string.Empty;
|
if (string.IsNullOrEmpty(key)) return string.Empty;
|
||||||
|
if (!_initialized) Initialize();
|
||||||
|
|
||||||
// 1. Try currently active locale
|
// 1. Try currently active locale
|
||||||
if (Locales.TryGetValue(CurrentLocaleCode, out var activeDict) && activeDict.TryGetValue(key, out var val))
|
if (Locales.TryGetValue(CurrentLocaleCode, out var activeDict) && activeDict.TryGetValue(key, out var val))
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ internal class RenderMod : MelonMod
|
|||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
GlobalSettings.Load();
|
GlobalSettings.Load();
|
||||||
|
Localization.LocalizationManager.Initialize();
|
||||||
ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory;
|
ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory;
|
||||||
|
|
||||||
var renderManagerObj = new GameObject("Render Manager");
|
var renderManagerObj = new GameObject("Render Manager");
|
||||||
|
|||||||
Reference in new issue
Block a user