i18n
This commit is contained in:
Executable
+42
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user