Skip to content

Commit

Permalink
fix(Czech): Fix recognition of the Czech language
Browse files Browse the repository at this point in the history
Also add fallback to english and log error
Fixes #586
Fixes #590
  • Loading branch information
Belphemur committed Apr 11, 2021
1 parent fe3d78b commit c4faedc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SoundSwitch/Localization/Factory/Lang/Langs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class Czech : ILang
/// <summary>
/// Culture info of this language
/// </summary>
public CultureInfo CultureInfo => CultureInfo.GetCultureInfo("cz");
public CultureInfo CultureInfo => CultureInfo.GetCultureInfo("cs");

public Language TypeEnum => Language.Czech;
public string Label => "Čeština";
Expand Down
12 changes: 10 additions & 2 deletions SoundSwitch/Localization/Factory/LanguageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Globalization;
using System.Linq;
using Serilog;
using SoundSwitch.Framework.Factory;
using SoundSwitch.Localization.Factory.Lang;

Expand Down Expand Up @@ -38,8 +39,15 @@ public LanguageFactory() : base(new EnumImplList<Language, ILang>
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;
}
}
}
}

0 comments on commit c4faedc

Please sign in to comment.