From c4faedcd2b6f926c6221b9803bca12ffba6b2b9b Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sun, 11 Apr 2021 09:15:25 -0400 Subject: [PATCH] fix(Czech): Fix recognition of the Czech language Also add fallback to english and log error Fixes #586 Fixes #590 --- SoundSwitch/Localization/Factory/Lang/Langs.cs | 2 +- SoundSwitch/Localization/Factory/LanguageFactory.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/SoundSwitch/Localization/Factory/Lang/Langs.cs b/SoundSwitch/Localization/Factory/Lang/Langs.cs index 278f214a48..bd97c00c54 100644 --- a/SoundSwitch/Localization/Factory/Lang/Langs.cs +++ b/SoundSwitch/Localization/Factory/Lang/Langs.cs @@ -195,7 +195,7 @@ public class Czech : ILang /// /// Culture info of this language /// - public CultureInfo CultureInfo => CultureInfo.GetCultureInfo("cz"); + public CultureInfo CultureInfo => CultureInfo.GetCultureInfo("cs"); public Language TypeEnum => Language.Czech; public string Label => "Čeština"; diff --git a/SoundSwitch/Localization/Factory/LanguageFactory.cs b/SoundSwitch/Localization/Factory/LanguageFactory.cs index 770bc45c05..cf8f02b4a5 100644 --- a/SoundSwitch/Localization/Factory/LanguageFactory.cs +++ b/SoundSwitch/Localization/Factory/LanguageFactory.cs @@ -1,5 +1,6 @@ using System.Globalization; using System.Linq; +using Serilog; using SoundSwitch.Framework.Factory; using SoundSwitch.Localization.Factory.Lang; @@ -38,8 +39,15 @@ public LanguageFactory() : base(new EnumImplList public Language GetWindowsLanguage() { var uiLang = CultureInfo.CurrentUICulture; - - return AllImplementations.Values.Where(value => value.CultureInfo.Equals(uiLang)).Select(value => value.TypeEnum).FirstOrDefault(); + try + { + return AllImplementations.Values.Where(value => value.CultureInfo.Equals(uiLang)).Select(value => value.TypeEnum).FirstOrDefault(); + } + catch (CultureNotFoundException e) + { + Log.Error(e,"Couldn't find the language @{lang}", uiLang); + return Language.English; + } } } } \ No newline at end of file