DutyContent/Locale.cs
ksh cbfa535d20
Enhanced after version 14 (#30)
* Add log tab
* Merge control mesg & duty log
* Fix ping (calc loss)
* Add current connection in ping tab. Able to copy by double clicking item
* Log font has moved to config
* Add debug enable on config + save
* Display ping failed reason (debug enable)
* Handled copy exception
* New content list in duty tab
* Show loss rate option in ping tab
* Rename Chinese packet info file (No data)
* Bigger UI font
2021-08-14 23:35:53 +09:00

52 lines
1.1 KiB
C#

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);
}
}
}