-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizationLoader.cs
38 lines (36 loc) · 1.07 KB
/
LocalizationLoader.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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Seva167.LanguagesMod
{
static class LocalizationLoader
{
public static void LoadLocalization(Localization locale)
{
foreach (var pair in locale.Dictionary)
{
Localizer.table.RemoveEntry(pair.Key);
Localizer.table.AddEntry(pair.Key, pair.Value);
}
}
public static Localization ReadLocalizationFromJson(string path)
{
try
{
string json = File.ReadAllText(path);
Localization localization = JsonConvert.DeserializeObject<Localization>(json);
localization.Code = Path.GetFileNameWithoutExtension(path);
return localization;
}
catch (Exception e)
{
PrimitierModdingFramework.PMFLog.Message(e.Message + e.StackTrace);
return null;
}
}
}
}