private void WorldCup_Load(object sender, EventArgs e) { string language = ""; try { language = AppSave.LanguageConfLoad(); } catch (FileNotFoundException) { language = "error"; } catch (Exception ex) { MessageBox.Show($"Error:\n {ex.Message}"); } pbIntro.Image = Resources.WC_Logo; btnEn.Visible = false; btnHr.Visible = false; if (language == "error") { btnEn.Visible = true; btnHr.Visible = true; } else { UpdateConfig("language", language); timerMain.Tick += TimerMain_Tick; timerMain.Interval = 500; timerMain.Start(); } }
private void SetCulture() { string culture; try { culture = AppSave.LanguageConfLoad(); if (culture == "hr-HR" || culture == "en-US") { var cultureInfo = new CultureInfo(culture); Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); } else { var cultureInfo = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); } } catch (Exception) { //log } }