Пример #1
0
        public static void SetupCulture()
        {
            var currentCulture = CultureInfo.CurrentCulture;

            var targetLocale = Settings.Default.Language;

            if (targetLocale.IsNotEmpty())
            {
                try
                {
                    currentCulture = SupportedLanguages.First(x => x.Name.Equals(targetLocale));
                }
                catch
                {
                    Settings.Default.Language = string.Empty;
                }
            }

            if (!currentCulture.Name.ContainsAny(SupportedLanguages.Select(x => x.Parent.Name),
                                                 StringComparison.OrdinalIgnoreCase))
            {
                currentCulture = EnUsCulture;
            }

            ProcessTools.SetDefaultCulture(currentCulture);
            var thread = Thread.CurrentThread;

            thread.CurrentCulture   = currentCulture;
            thread.CurrentUICulture = currentCulture;
        }