Files
shadowsocks-windows/shadowsocks-csharp/Controller/I18N.cs
T
kimw 758c497eba same the source code format.
1/ removed dual empty line
2/ removed tailing spaces
3/ converted tabs into spaces
4/ added some TODO comments
2015-08-19 00:24:08 +08:00

47 lines
1.3 KiB
C#
Executable File

using Shadowsocks.Properties;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace Shadowsocks.Controller
{
public class I18N
{
protected static Dictionary<string, string> Strings;
static I18N()
{
Strings = new Dictionary<string, string>();
if (System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag.ToLowerInvariant().StartsWith("zh"))
{
string[] lines = Regex.Split(Resources.cn, "\r\n|\r|\n");
foreach (string line in lines)
{
if (line.StartsWith("#"))
{
continue;
}
string[] kv = Regex.Split(line, "=");
if (kv.Length == 2)
{
Strings[kv[0]] = kv[1];
}
}
}
}
public static string GetString(string key)
{
if (Strings.ContainsKey(key))
{
return Strings[key];
}
else
{
return key;
}
}
}
}