From c3007d3aadb891b0127b703a7667d3bd5177b75a Mon Sep 17 00:00:00 2001 From: Chance Millar Date: Tue, 7 May 2024 20:08:22 +0100 Subject: [PATCH] Implemented temporary fallback for unsupported languages. --- src/G2DataGUI.UI.Common/Locale/LocaleManager.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/G2DataGUI.UI.Common/Locale/LocaleManager.cs b/src/G2DataGUI.UI.Common/Locale/LocaleManager.cs index 5221b0c..b7d31eb 100644 --- a/src/G2DataGUI.UI.Common/Locale/LocaleManager.cs +++ b/src/G2DataGUI.UI.Common/Locale/LocaleManager.cs @@ -23,7 +23,7 @@ private LocaleManager() public void Load() { - string systemLanguageCode = CultureInfo.CurrentCulture.Name.Replace("-", "_"); + string systemLanguageCode = GetSupportedLanguage(); LoadLanguage(systemLanguageCode); LoadDefaultLanguage(); } @@ -36,9 +36,17 @@ public void LoadLanguage(string languageCode) } } - private void LoadDefaultLanguage() => _defaultLocaleStringLists = LoadJsonLanguage(); + private void LoadDefaultLanguage() => _defaultLocaleStringLists = LoadJsonLanguage(); - private Dictionary> LoadJsonLanguage(string languageCode = DefaultLanguageCode) + private string GetSupportedLanguage() + { + string systemLanguage = CultureInfo.CurrentCulture.Name.Replace("-", "_"); + + // Todo: Check if systemLanguage is in supported locales, at the moment it's only en_US. + return DefaultLanguageCode; + } + + private Dictionary> LoadJsonLanguage(string languageCode = DefaultLanguageCode) { Dictionary> localeStringLists = new(); string jsonData = EmbeddedResources.ReadAllText($"G2DataGUI.UI.Common/Assets/Locales/{languageCode}.json");