diff --git a/shadowsocks-csharp/Controller/I18N.cs b/shadowsocks-csharp/Controller/I18N.cs index 608492cf..7102b79a 100755 --- a/shadowsocks-csharp/Controller/I18N.cs +++ b/shadowsocks-csharp/Controller/I18N.cs @@ -12,7 +12,7 @@ namespace Shadowsocks.Controller public static class I18N { - private static readonly string I18N_FILE = "i18n.csv"; + public const string I18N_FILE = "i18n.csv"; private static Dictionary _strings = new Dictionary(); @@ -45,14 +45,16 @@ namespace Shadowsocks.Controller if (localeNames[i].Split('-')[0] == localeNoRegion) targetIndex = i; } - Logging.Info($"Using {localeNames[targetIndex]} translation for {locale}"); - } - - // Still not found, exit - if (targetIndex == -1 || enIndex == targetIndex) - { - Logging.Info($"Translation for {locale} not found"); - return; + if (targetIndex != -1 && enIndex != targetIndex) + { + Logging.Info($"Using {localeNames[targetIndex]} translation for {locale}"); + } + else + { + // Still not found, exit + Logging.Info($"Translation for {locale} not found"); + return; + } } // read translation lines @@ -75,17 +77,19 @@ namespace Shadowsocks.Controller static I18N() { string i18n; + string locale = CultureInfo.CurrentCulture.Name; if (!File.Exists(I18N_FILE)) { i18n = Resources.i18n_csv; - File.WriteAllText(I18N_FILE, i18n, Encoding.UTF8); + //File.WriteAllText(I18N_FILE, i18n, Encoding.UTF8); } else { + Logging.Info("Using external translation"); i18n = File.ReadAllText(I18N_FILE, Encoding.UTF8); } - Logging.Info("Current language is: " + CultureInfo.CurrentCulture.Name); - Init(i18n, CultureInfo.CurrentCulture.Name); + Logging.Info("Current language is: " + locale); + Init(i18n, locale); } public static string GetString(string key, params object[] args) diff --git a/shadowsocks-csharp/Data/i18n.csv b/shadowsocks-csharp/Data/i18n.csv index 2ca5fc2e..c9f8b48b 100644 --- a/shadowsocks-csharp/Data/i18n.csv +++ b/shadowsocks-csharp/Data/i18n.csv @@ -46,6 +46,7 @@ Load Balance,负载均衡,負載平衡,負荷分散 High Availability,高可用,高可用性,高可用性 Choose by statistics,根据统计,根據統計,統計で選ぶ Show Plugin Output,显示插件输出,, +Write translation template,写入翻译模板,, ,,, # Config Form,,, ,,, diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index a1d9b820..18d0e1b0 100644 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -1,21 +1,18 @@ -using System; +using Shadowsocks.Controller; +using Shadowsocks.Model; +using Shadowsocks.Properties; +using Shadowsocks.Util; +using System; using System.Diagnostics; using System.Drawing; -using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Text; using System.Windows.Forms; - using ZXing; using ZXing.Common; using ZXing.QrCode; -using Shadowsocks.Controller; -using Shadowsocks.Model; -using Shadowsocks.Properties; -using Shadowsocks.Util; -using System.Linq; -using Microsoft.Win32; -using System.Windows.Interop; - namespace Shadowsocks.View { public class MenuViewController @@ -56,6 +53,7 @@ namespace Shadowsocks.View private MenuItem hotKeyItem; private MenuItem VerboseLoggingToggleItem; private MenuItem ShowPluginOutputToggleItem; + private MenuItem WriteI18NFileItem; private ConfigForm configForm; private ProxyForm proxyForm; @@ -322,6 +320,7 @@ namespace Shadowsocks.View CreateMenuItem("Show Logs...", new EventHandler(this.ShowLogItem_Click)), this.VerboseLoggingToggleItem = CreateMenuItem( "Verbose Logging", new EventHandler(this.VerboseLoggingToggleItem_Click) ), this.ShowPluginOutputToggleItem = CreateMenuItem("Show Plugin Output", new EventHandler(this.ShowPluginOutputToggleItem_Click)), + this.WriteI18NFileItem = CreateMenuItem("Write translation template",new EventHandler(WriteI18NFileItem_Click)), CreateMenuGroup("Updates...", new MenuItem[] { CreateMenuItem("Check for Updates...", new EventHandler(this.checkUpdatesItem_Click)), new MenuItem("-"), @@ -718,6 +717,11 @@ namespace Shadowsocks.View controller.ToggleShowPluginOutput(ShowPluginOutputToggleItem.Checked); } + private void WriteI18NFileItem_Click(object sender, EventArgs e) + { + File.WriteAllText(I18N.I18N_FILE, Resources.i18n_csv, Encoding.UTF8); + } + private void StatisticsConfigItem_Click(object sender, EventArgs e) { StatisticsStrategyConfigurationForm form = new StatisticsStrategyConfigurationForm(controller);