Skip to content

Commit

Permalink
🌐 Set culture to LocalizeDictionary instance
Browse files Browse the repository at this point in the history
- Workaround for ElementHost bug
  • Loading branch information
database64128 committed Oct 18, 2020
1 parent 01f7882 commit d6d105f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shadowsocks-csharp/Controller/ShadowsocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Shadowsocks.Controller.Strategy;
using Shadowsocks.Model;
using Shadowsocks.Util;
using WPFLocalizeExtension.Engine;

namespace Shadowsocks.Controller
{
Expand Down Expand Up @@ -172,6 +173,8 @@ protected void Reload()

NLogConfig.LoadConfiguration();

logger.Info($"WPF Localization Extension|Current culture: {LocalizeDictionary.CurrentCulture}");

// set User-Agent for httpClient
try
{
Expand Down
7 changes: 7 additions & 0 deletions shadowsocks-csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Shadowsocks.Util;
using Shadowsocks.View;
using Splat;
using WPFLocalizeExtension.Engine;

namespace Shadowsocks
{
Expand Down Expand Up @@ -116,6 +117,12 @@ private static void Main(string[] args)
// 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");
Expand Down

0 comments on commit d6d105f

Please sign in to comment.