Fix language detection
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
This commit is contained in:
@@ -7,11 +7,11 @@ namespace Shadowsocks.Controller
|
||||
{
|
||||
using Shadowsocks.Properties;
|
||||
|
||||
public class I18N
|
||||
public static class I18N
|
||||
{
|
||||
protected static Dictionary<string, string> Strings;
|
||||
private static Dictionary<string, string> _strings = new Dictionary<string, string>();
|
||||
|
||||
static void Init(string res)
|
||||
private static void Init(string res)
|
||||
{
|
||||
using (var sr = new StringReader(res))
|
||||
{
|
||||
@@ -23,38 +23,28 @@ namespace Shadowsocks.Controller
|
||||
var pos = line.IndexOf('=');
|
||||
if (pos < 1)
|
||||
continue;
|
||||
Strings[line.Substring(0, pos)] = line.Substring(pos + 1);
|
||||
_strings[line.Substring(0, pos)] = line.Substring(pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static I18N()
|
||||
{
|
||||
Strings = new Dictionary<string, string>();
|
||||
string name = CultureInfo.CurrentCulture.Name;
|
||||
if (name.StartsWith("zh"))
|
||||
string name = CultureInfo.CurrentCulture.EnglishName;
|
||||
if (name.StartsWith("Chinese", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (name == "zh" || name == "zh-CN")
|
||||
{
|
||||
Init(Resources.cn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Init(Resources.zh_tw);
|
||||
}
|
||||
// choose Traditional Chinese only if we get explicit indication
|
||||
Init(name.Contains("Traditional")
|
||||
? Resources.zh_tw
|
||||
: Resources.cn);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetString(string key)
|
||||
{
|
||||
if (Strings.ContainsKey(key))
|
||||
{
|
||||
return Strings[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
return key;
|
||||
}
|
||||
return _strings.ContainsKey(key)
|
||||
? _strings[key]
|
||||
: key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user