diff --git a/src/DynamoApplications/StartupUtils.cs b/src/DynamoApplications/StartupUtils.cs index e4b75db05a0..280d7bcadb9 100644 --- a/src/DynamoApplications/StartupUtils.cs +++ b/src/DynamoApplications/StartupUtils.cs @@ -245,9 +245,7 @@ private static IUpdateManager InitializeUpdateManager() { IPathResolver pathResolver = CreatePathResolver(false, string.Empty, string.Empty, string.Empty); PathManager.Instance.AssignHostPathAndIPathResolver(string.Empty, pathResolver); - - Thread.CurrentThread.CurrentUICulture = new CultureInfo(PreferenceSettings.Instance.Locale); - Thread.CurrentThread.CurrentCulture = new CultureInfo(PreferenceSettings.Instance.Locale); + DynamoModel.SetUICulture(PreferenceSettings.Instance.Locale); DynamoModel.OnDetectLanguage(); // Preload ASM and display corresponding message on splash screen @@ -284,9 +282,7 @@ public static DynamoModel MakeModel(bool CLImode, string asmPath = "", string ho { IPathResolver pathResolver = CreatePathResolver(false, string.Empty, string.Empty, string.Empty); PathManager.Instance.AssignHostPathAndIPathResolver(string.Empty, pathResolver); - - Thread.CurrentThread.CurrentUICulture = new CultureInfo(PreferenceSettings.Instance.Locale); - Thread.CurrentThread.CurrentCulture = new CultureInfo(PreferenceSettings.Instance.Locale); + DynamoModel.SetUICulture(PreferenceSettings.Instance.Locale); DynamoModel.OnDetectLanguage(); // Preload ASM and display corresponding message on splash screen @@ -425,8 +421,7 @@ public static string SetLocale(CommandLineArguments cmdLineArgs) if (!string.IsNullOrEmpty(cmdLineArgs.Locale)) { // Change the application locale, if a locale information is supplied. - Thread.CurrentThread.CurrentUICulture = new CultureInfo(cmdLineArgs.Locale); - Thread.CurrentThread.CurrentCulture = new CultureInfo(cmdLineArgs.Locale); + DynamoModel.SetUICulture(cmdLineArgs.Locale); libgLocale = cmdLineArgs.Locale; } else diff --git a/src/DynamoCore/Configuration/Configurations.cs b/src/DynamoCore/Configuration/Configurations.cs index 60c4a34870d..fa2a42ea0fd 100644 --- a/src/DynamoCore/Configuration/Configurations.cs +++ b/src/DynamoCore/Configuration/Configurations.cs @@ -377,7 +377,7 @@ public class Configurations /// /// Supported locales as a list /// - internal static readonly List SupportedLocaleList = new List() { "en-US", "cs-CZ", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "zh-CN", "zh-TW" }; + internal static readonly List SupportedLocaleList = new List() { "Default", "en-US", "cs-CZ", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "zh-CN", "zh-TW" }; /// /// Supported languages and locales as a dictionary in the current thread locale diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs index 4ca4738f112..e05d3e69c90 100644 --- a/src/DynamoCore/Models/DynamoModel.cs +++ b/src/DynamoCore/Models/DynamoModel.cs @@ -681,6 +681,13 @@ protected DynamoModel(IStartConfiguration config) PreferenceSettings = (PreferenceSettings)CreateOrLoadPreferences(config.Preferences); if (PreferenceSettings != null) { + // Setting the locale for Dynamo from loaded Preferences only when + // In a non-in-process integration case (when HostAnalyticsInfo.HostName is unspecified) + // Language is specified, otherwise Default setting means following host locale + if (string.IsNullOrEmpty(HostAnalyticsInfo.HostName) || !PreferenceSettings.Locale.Equals(Configuration.Configurations.SupportedLocaleList.First())) + { + SetUICulture(PreferenceSettings.Locale); + } PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged; PreferenceSettings.MessageLogged += LogMessage; } @@ -2698,6 +2705,15 @@ internal bool CanDumpLibraryToXml(object obj) #region public methods + /// + /// Set UI culture based on preferences + /// + public static void SetUICulture(string locale) + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo(locale == "Default" ? "en-US" : locale); + Thread.CurrentThread.CurrentCulture = new CultureInfo(locale == "Default" ? "en-US" : locale); + } + /// /// Add a new HomeWorkspace and set as current /// diff --git a/src/DynamoCore/Properties/Resources.Designer.cs b/src/DynamoCore/Properties/Resources.Designer.cs index 917980b34bc..f523c41ad4c 100644 --- a/src/DynamoCore/Properties/Resources.Designer.cs +++ b/src/DynamoCore/Properties/Resources.Designer.cs @@ -570,7 +570,7 @@ public static string DuplicateMigrationTypeRegistered { } /// - /// Looks up a localized string similar to English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文. + /// Looks up a localized string similar to Default,English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文. /// public static string DynamoLanguages_noxlate { get { diff --git a/src/DynamoCore/Properties/Resources.en-US.resx b/src/DynamoCore/Properties/Resources.en-US.resx index 70da17d6afc..b40c51c4764 100644 --- a/src/DynamoCore/Properties/Resources.en-US.resx +++ b/src/DynamoCore/Properties/Resources.en-US.resx @@ -900,7 +900,7 @@ This package likely contains an assembly that is blocked. You will need to load Example file added to workspace. Run mode changed to Manual. - English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文 + Default,English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文 Formula failed to convert to DesignScript code. Please edit the formula manually to use it in a CodeBlock node. diff --git a/src/DynamoCore/Properties/Resources.resx b/src/DynamoCore/Properties/Resources.resx index 523bd8cf3ea..77d3d8340dd 100644 --- a/src/DynamoCore/Properties/Resources.resx +++ b/src/DynamoCore/Properties/Resources.resx @@ -903,7 +903,7 @@ This package likely contains an assembly that is blocked. You will need to load Example file added to workspace. Run mode changed to Manual. - English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文 + Default,English,Čeština,Deutsch,Español,Français,Italiano,日本語,한국어,Polski,Português (Brasil),Русский,简体中文,繁體中文 Formula failed to convert to DesignScript code. Please edit the formula manually to use it in a CodeBlock node. diff --git a/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs b/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs index 0b1880756b0..9545df367c1 100644 --- a/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs +++ b/test/DynamoCoreTests/Configuration/PreferenceSettingsTests.cs @@ -70,7 +70,7 @@ public void TestSettingsSerialization() Assert.AreEqual(settings.ViewExtensionSettings.Count, 0); Assert.AreEqual(settings.DefaultRunType, RunType.Automatic); Assert.AreEqual(settings.DynamoPlayerFolderGroups.Count, 0); - Assert.AreEqual(settings.Locale, "en-US"); + Assert.AreEqual(settings.Locale, "Default"); // Save settings.Save(tempPath); @@ -89,7 +89,7 @@ public void TestSettingsSerialization() Assert.AreEqual(settings.ViewExtensionSettings.Count, 0); Assert.AreEqual(settings.DefaultRunType, RunType.Automatic); Assert.AreEqual(settings.DynamoPlayerFolderGroups.Count, 0); - Assert.AreEqual(settings.Locale, "en-US"); + Assert.AreEqual(settings.Locale, "Default"); // Change setting values settings.SetIsBackgroundPreviewActive("MyBackgroundPreview", false);