-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguageManager.cs
41 lines (36 loc) · 1.33 KB
/
LanguageManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using UnityEngine.Localization.Settings;
namespace Seva167.LanguagesMod
{
static class LanguageManager
{
public static UnityEngine.Localization.Locale[] UnityLocales { get; private set; }
private static Localization[] locales;
public static void LoadAllLocales()
{
string[] localeFiles = Directory.GetFiles(Mod.LocalizationsFolder);
locales = new Localization[localeFiles.Length];
UnityLocales = new UnityEngine.Localization.Locale[localeFiles.Length];
for (int i = 0; i < locales.Length; i++)
{
locales[i] = LocalizationLoader.ReadLocalizationFromJson(localeFiles[i]);
UnityLocales[i] = UnityEngine.Localization.Locale.CreateLocale(locales[i].Code);
UnityLocales[i].LocaleName = locales[i].Name;
}
}
public static Localization GetLocalizationFromUnityLocale(UnityEngine.Localization.Locale locale)
{
foreach (var localization in locales)
{
if (locale.Identifier.Code == localization.Code)
return localization;
}
return null;
}
}
}