forked from kshman/DutyContent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocale.cs
52 lines (43 loc) · 1.13 KB
/
Locale.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
42
43
44
45
46
47
48
49
50
51
52
using System.Text;
namespace DutyContent
{
static class Locale
{
private static ThirdParty.LineDb _lines;
public static string Language { get; private set; }
public static void Initialize(string text)
{
_lines = new ThirdParty.LineDb(text, true);
}
public static bool LoadFile(string filename, Encoding enc)
{
if (_lines == null)
return false;
else
{
_lines.LoadFile(filename, enc, true);
return true;
}
}
public static bool LoadFile(string filename)
{
return LoadFile(filename, Encoding.UTF8);
}
public static string Text(string text)
{
return _lines == null || !_lines.Try(text, out string v) ? $"<{text}>" : v;
}
public static string Text(string text, params object[] prms)
{
return _lines == null || !_lines.Try(text, out string v) ? $"<{text}>" : string.Format(v, prms);
}
public static string Text(int key)
{
return _lines == null || !_lines.Try(key, out string v) ? $"<{key}>" : v;
}
public static string Text(int key, params object[] prms)
{
return _lines == null || !_lines.Try(key, out string v) ? $"<{key}>" : string.Format(v, prms);
}
}
}