SIL.FieldWorks.FieldWorks.SetUICulture C# (CSharp) Méthode

SetUICulture() private static méthode

Sets the UI culture.
private static SetUICulture ( SIL.FieldWorks.Common.FwUtils.FwAppArgs args ) : bool
args SIL.FieldWorks.Common.FwUtils.FwAppArgs The application arguments
Résultat bool
		private static bool SetUICulture(FwAppArgs args)
		{
			// Try the UI locale found on the command-line (if any).
			string locale = args.Locale;
			// If that doesn't exist, try the UI locale found in the registry.
			if (string.IsNullOrEmpty(locale))
				locale = (string)FwRegistryHelper.FieldWorksRegistryKey.GetValue(FwRegistryHelper.UserLocaleValueName, string.Empty);
			// If that doesn't exist, try the current system UI locale set at program startup
			// This is typically en-US, but we want this to match en since our English localizations use en.
			if (string.IsNullOrEmpty(locale) && Thread.CurrentThread.CurrentUICulture != null)
			{
				locale = Thread.CurrentThread.CurrentUICulture.Name;
				if (locale.StartsWith("en-"))
					locale = "en";
			}
			// If that doesn't exist, just use English ("en").
			if (string.IsNullOrEmpty(locale))
			{
				locale = "en";
			}
			else if (locale != "en")
			{
				// Check whether the desired locale has a localization, ignoring the
				// country code if necessary.  Fall back to English ("en") if no
				// localization exists.
				var rgsLangs = GetAvailableLangsFromSatelliteDlls();
				if (!rgsLangs.Contains(locale))
				{
					var originalLocale = locale;
					int idx = locale.IndexOf('-');
					if (idx > 0)
						locale = locale.Substring(0, idx);
					if (!rgsLangs.Contains(locale))
					{
						if (MessageBox.Show(string.Format(Properties.Resources.kstidFallbackToEnglishUi, originalLocale),
							Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.No)
						{
							return false;
						}
						locale = "en";
						FwRegistryHelper.FieldWorksRegistryKey.SetValue(FwRegistryHelper.UserLocaleValueName, locale);
					}
				}
			}
			if (locale != Thread.CurrentThread.CurrentUICulture.Name)
				Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(locale);

			s_sWsUser = Thread.CurrentThread.CurrentUICulture.Name;
			return true;
		}
FieldWorks