-
Notifications
You must be signed in to change notification settings - Fork 1
/
Translations.cs
36 lines (34 loc) · 1.49 KB
/
Translations.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
global using static SItemModifier.Translations;
namespace SItemModifier;
// Don't rename this class, it will be used in analyzer.
public static partial class Translations
{
#region Base
public static char[] TranslationKeyTrimCharacters = new[] { '_' };
/// <summary>
/// Retrieves values from <see cref="Translations"/> type. [Only "<see langword="public"/> <see langword="static"/> <see langword="readonly"/> <see langword="string"/>" or
/// "<see langword="public"/> <see langword="const"/> <see langword="string"/>" fields]
/// </summary>
public static TranslationList DefaultTranslationList
{
get
{
var translations = new TranslationList();
translations.AddRange(
typeof(Translations).GetFields(BindingFlags.Static | BindingFlags.Public)
.Where(x => x.IsStatic || x.IsLiteral)
.Select(x =>
new TranslationListEntry(x.Name.Trim(TranslationKeyTrimCharacters), (x.IsLiteral ? x.GetRawConstantValue() : x.GetValue(null)).ToString())
));
return translations;
}
}
/// <summary>
/// This method is important for analyzer!
/// </summary>
public static string Translate(string translationKey, params object[] arguments) => inst.Translate(translationKey, arguments);
#endregion
// You can write static/const string fields(translations) here. By default _ will be trimmed
public const string
Hello = "Hello from RocketMod.Modern!";
}