public static void LoadLanguage(ELanguage language) { App.Logger.Log($"[LOCALIZATION] - Loading {language} localization..."); try { using (StreamReader sr = new StreamReader(Application.GetResourceStream(new Uri($"Resources/Localization/{language}.json", UriKind.Relative)).Stream)) { string text = sr.ReadToEnd(); Current = Newtonsoft.Json.JsonConvert.DeserializeObject <Localization>(text); IsLoaded = true; } if (AppConfig.Instance.replaceMissingKeysWithEnglish && language != ELanguage.English) { App.Logger.Log("[LOCALIZATION] - Replacing missing keys..."); using (StreamReader sr = new StreamReader(Application.GetResourceStream(new Uri($"Resources/Localization/{ELanguage.English}.json", UriKind.Relative)).Stream)) { string text = sr.ReadToEnd(); var secondary = Newtonsoft.Json.JsonConvert.DeserializeObject <Localization>(text); Current.AddMissingKeys(secondary); } } } catch (Exception ex) { App.Logger.LogException($"[LOCALIZATION] - Could not load {language} localization.", ex: ex); } }