add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
@@ -0,0 +1,85 @@
using System;
using UnityEngine;
using UnityEngine.Events;
using OHM.UnityToolkit;
namespace OHM.UnityToolkit.Localization
{
public class LocalizationManager : UniqueInstance<LocalizationManager>
{
public LocalesList localesList;
public bool autoSetLang;
public UnityEvent OnLangChanged;
private bool _showDebug;
public LocaleDef CurrentLocale { get; private set; }
protected override void AwakeInstance()
{
if (autoSetLang)
{
SetLanguage(Application.systemLanguage);
}
}
public void SetLanguage(SystemLanguage lang)
{
CurrentLocale = null;
if (localesList == null || localesList.locales == null || localesList.locales.Count < 1)
{
Debug.LogError("No locale defined");
return;
}
if (lang == SystemLanguage.Unknown)
{
lang = Application.systemLanguage;
}
foreach (LocaleDef locale in localesList.locales)
{
if (locale.language == lang)
{
CurrentLocale = locale;
}
}
if (CurrentLocale == null)
{
CurrentLocale = localesList.locales[0];
Debug.Log("No specific locale found for language" + lang + ". Using default : " + CurrentLocale.language);
}
OnLangChanged.Invoke();
}
public void TestLocale(LocaleDef locale)
{
CurrentLocale = locale;
OnLangChanged.Invoke();
}
public string Localize(string key)
{
return LocalizationUtils.Localize(CurrentLocale, key);
}
public string LocalizeFormat(string key, object[] args)
{
string localized = LocalizationUtils.Localize(CurrentLocale, key);
try
{
localized = string.Format(localized, args);
}
catch (FormatException)
{
Debug.LogWarningFormat("Locale key {0} does not match the required format", key);
}
return localized;
}
public void DrawDebug()
{
}
}
}