Skip to content

Commit

Permalink
update set locale function
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed Nov 20, 2023
1 parent 96fb3f0 commit a314502
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,7 @@ 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);
}
SetUICulture(PreferenceSettings.Locale);
PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
PreferenceSettings.MessageLogged += LogMessage;
}
Expand Down Expand Up @@ -2723,8 +2717,23 @@ internal bool CanDumpLibraryToXml(object obj)
/// </summary>
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);
if (string.IsNullOrWhiteSpace(locale)) return;

// Setting the locale for Dynamo from loaded Preferences, with Default handled differently
// between a non-in-process integration case (when HostAnalyticsInfo.HostName is unspecified)
// and in-process integration case. In later case, Default setting means following host locale.
if (string.IsNullOrEmpty(HostAnalyticsInfo.HostName))
{
// Sandbox default to en-US
Thread.CurrentThread.CurrentUICulture = new CultureInfo(locale == "Default" ? "en-US" : locale);
Thread.CurrentThread.CurrentCulture = new CultureInfo(locale == "Default" ? "en-US" : locale);
}
else
{
// Integration default to
Thread.CurrentThread.CurrentUICulture = locale == "Default" ? System.Globalization.CultureInfo.DefaultThreadCurrentCulture : new CultureInfo(locale);
Thread.CurrentThread.CurrentCulture = locale == "Default" ? System.Globalization.CultureInfo.DefaultThreadCurrentCulture : new CultureInfo(locale);
}
}

/// <summary>
Expand Down

0 comments on commit a314502

Please sign in to comment.