-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathLocalizationRoundabout.cs
37 lines (32 loc) · 1.05 KB
/
LocalizationRoundabout.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
using System;
using System.Reflection;
namespace StarlightRiver
{
internal class LocalizationRewriter : ModSystem
{
public override void PostSetupContent()
{
#if DEBUG
MethodInfo refreshInfo = typeof(LocalizationLoader).GetMethod("UpdateLocalizationFilesForMod", BindingFlags.NonPublic | BindingFlags.Static, new Type[] { typeof(Mod), typeof(string), typeof(GameCulture) });
refreshInfo.Invoke(null, new object[] { Mod, null, Language.ActiveCulture });
#endif
}
}
internal static class LocalizationRoundabout
{
public static void SetDefault(this LocalizedText text, string value)
{
#if DEBUG
PropertyInfo valueProp = typeof(LocalizedText).GetProperty("Value", BindingFlags.Public | BindingFlags.Instance);
LanguageManager.Instance.GetOrRegister(text.Key, () => value);
valueProp.SetValue(text, value);
#endif
}
public static LocalizedText DefaultText(string key, string english)
{
LocalizedText text = Language.GetOrRegister($"Mods.StarlightRiver.{key}", () => english);
text.SetDefault(english);
return text;
}
}
}