diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index d1491cbd..06238c04 100644 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -16,6 +16,7 @@ using Shadowsocks.Controller.Service; using Shadowsocks.Controller.Strategy; using Shadowsocks.Model; using Shadowsocks.Util; +using WPFLocalizeExtension.Engine; namespace Shadowsocks.Controller { @@ -172,6 +173,8 @@ namespace Shadowsocks.Controller NLogConfig.LoadConfiguration(); + logger.Info($"WPF Localization Extension|Current culture: {LocalizeDictionary.CurrentCulture}"); + // set User-Agent for httpClient try { diff --git a/shadowsocks-csharp/Program.cs b/shadowsocks-csharp/Program.cs index a76633fd..520f4676 100755 --- a/shadowsocks-csharp/Program.cs +++ b/shadowsocks-csharp/Program.cs @@ -17,6 +17,7 @@ using Shadowsocks.Controller.Hotkeys; using Shadowsocks.Util; using Shadowsocks.View; using Splat; +using WPFLocalizeExtension.Engine; namespace Shadowsocks { @@ -116,6 +117,12 @@ namespace Shadowsocks // Parameters would have to be dropped from views' constructors (VersionUpdatePromptView) //Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly()); + // Workaround for hosting WPF controls in a WinForms app. + // We have to manually set the culture for the LocalizeDictionary instance. + // https://stackoverflow.com/questions/374518/localizing-a-winforms-application-with-embedded-wpf-user-controls + // https://stackoverflow.com/questions/14668640/wpf-localize-extension-translate-window-at-run-time + LocalizeDictionary.Instance.Culture = Thread.CurrentThread.CurrentCulture; + #if DEBUG // truncate privoxy log file while debugging string privoxyLogFilename = Utils.GetTempPath("privoxy.log");