From 5445097b82b87eba483c9b755855e34565513c46 Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Thu, 15 Feb 2024 18:26:20 -0500 Subject: [PATCH] Hide languages from list if unsupported by OS --- src/LanguageDialog.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/LanguageDialog.cs b/src/LanguageDialog.cs index c0c65d1..1870d45 100644 --- a/src/LanguageDialog.cs +++ b/src/LanguageDialog.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Windows.Forms; namespace WinDynamicDesktop @@ -26,9 +27,16 @@ private void LanguageDialog_Load(object sender, EventArgs e) { foreach (string langCode in Localization.languageCodes) { - languageNames.Add(new CultureInfo(langCode).NativeName); + try + { + languageNames.Add(new CultureInfo(langCode).NativeName); + } + catch (CultureNotFoundException) + { + languageNames.Add(null); + } } - comboBox1.Items.AddRange(languageNames.ToArray()); + comboBox1.Items.AddRange(languageNames.Where(x => x != null).ToArray()); comboBox1.Sorted = true; int langIndex = Array.IndexOf(Localization.languageCodes, Localization.currentLocale);