SHA256
forked from ADOFAIEditorForum/ADOFAIRenderer
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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MelonLoader;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
@@ -33,6 +32,11 @@ internal static class LocalizationManager
|
||||
|
||||
private static bool _initialized;
|
||||
|
||||
static LocalizationManager()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the localization system and loads embedded language dictionaries.
|
||||
/// </summary>
|
||||
@@ -115,7 +119,7 @@ internal static class LocalizationManager
|
||||
localeCode = FallbackLocaleCode;
|
||||
}
|
||||
|
||||
var isChanged = (language != CurrentLanguage) || (localeCode != CurrentLocaleCode);
|
||||
var isChanged = language != CurrentLanguage || localeCode != CurrentLocaleCode;
|
||||
|
||||
CurrentLanguage = language;
|
||||
CurrentLocaleCode = localeCode;
|
||||
@@ -140,6 +144,7 @@ internal static class LocalizationManager
|
||||
public static string Get(string key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key)) return string.Empty;
|
||||
if (!_initialized) Initialize();
|
||||
|
||||
// 1. Try currently active locale
|
||||
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()
|
||||
{
|
||||
GlobalSettings.Load();
|
||||
Localization.LocalizationManager.Initialize();
|
||||
ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory;
|
||||
|
||||
var renderManagerObj = new GameObject("Render Manager");
|
||||
|
||||
Reference in new issue
Block a user