Browse Source

🌐 Set culture to LocalizeDictionary instance

- Workaround for ElementHost bug
tags/4.3.0.0
database64128 4 years ago
parent
commit
d6d105fbc8
No known key found for this signature in database GPG Key ID: 1CA27546BEDB8B01
2 changed files with 10 additions and 0 deletions
  1. +3
    -0
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  2. +7
    -0
      shadowsocks-csharp/Program.cs

+ 3
- 0
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -16,6 +16,7 @@ using Shadowsocks.Controller.Service;
using Shadowsocks.Controller.Strategy; using Shadowsocks.Controller.Strategy;
using Shadowsocks.Model; using Shadowsocks.Model;
using Shadowsocks.Util; using Shadowsocks.Util;
using WPFLocalizeExtension.Engine;
namespace Shadowsocks.Controller namespace Shadowsocks.Controller
{ {
@@ -172,6 +173,8 @@ namespace Shadowsocks.Controller
NLogConfig.LoadConfiguration(); NLogConfig.LoadConfiguration();
logger.Info($"WPF Localization Extension|Current culture: {LocalizeDictionary.CurrentCulture}");
// set User-Agent for httpClient // set User-Agent for httpClient
try try
{ {


+ 7
- 0
shadowsocks-csharp/Program.cs View File

@@ -17,6 +17,7 @@ using Shadowsocks.Controller.Hotkeys;
using Shadowsocks.Util; using Shadowsocks.Util;
using Shadowsocks.View; using Shadowsocks.View;
using Splat; using Splat;
using WPFLocalizeExtension.Engine;
namespace Shadowsocks namespace Shadowsocks
{ {
@@ -116,6 +117,12 @@ namespace Shadowsocks
// Parameters would have to be dropped from views' constructors (VersionUpdatePromptView) // Parameters would have to be dropped from views' constructors (VersionUpdatePromptView)
//Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly()); //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 #if DEBUG
// truncate privoxy log file while debugging // truncate privoxy log file while debugging
string privoxyLogFilename = Utils.GetTempPath("privoxy.log"); string privoxyLogFilename = Utils.GetTempPath("privoxy.log");


Loading…
Cancel
Save