This commit is contained in:
clowwindy
2014-12-20 16:56:25 +08:00
parent 254f0ef622
commit 52ca609e3e
10 changed files with 255 additions and 105 deletions
+42
View File
@@ -0,0 +1,42 @@
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)
{
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;
}
}
}
}
@@ -61,7 +61,7 @@ namespace Shadowsocks.Controller
SocketException se = (SocketException)e;
if (se.SocketErrorCode == SocketError.AccessDenied)
{
e = new Exception("Port is already used", e);
e = new Exception(I18N.GetString("Port is already used"), e);
}
}
Errored(this, new ErrorEventArgs(e));