-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslations.cs
40 lines (39 loc) · 1.76 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
37
38
39
40
global using static SMembersInfo.Translations;
namespace SMembersInfo
{
// 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.IsInitOnly) || 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
Format = "Members of {0}",
FormatAll = "Factions:",
FactionFormat = "{0} - {1} players ({2:0.00}%)",
MemberFormat = "{0}. {1} - {2}";
}
}