diff --git a/CHANGELOG.md b/CHANGELOG.md index a0dfa92..fc6d929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Exposed SafeSubst and SafeSubstByKey on SimpleError (#104) ### Fixed +- Language selection is not persisted across Unity Editor restarts or domain reloads (#108) - Exceptions leaking out of language change callbacks break subsequent callbacks (#103) - Deregistering a language change callback while callbacks are running could skip executing some callbacks (#103) diff --git a/Editor/UI/Localization/LanguagePrefs.cs b/Editor/UI/Localization/LanguagePrefs.cs index 186ebbe..de3ac59 100644 --- a/Editor/UI/Localization/LanguagePrefs.cs +++ b/Editor/UI/Localization/LanguagePrefs.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Runtime.CompilerServices; +using UnityEditor; using UnityEngine; namespace nadena.dev.ndmf.localization @@ -11,8 +12,15 @@ namespace nadena.dev.ndmf.localization /// public static class LanguagePrefs { + private const string EditorPrefKey = "nadena.dev.ndmf.language-selection"; private static string _curLanguage = "en-us"; + [InitializeOnLoadMethod] + private static void Init() + { + Language = EditorPrefs.GetString(EditorPrefKey, "en-US"); + } + /// /// The currently selected language ID, e.g. "en-us". /// @@ -23,6 +31,7 @@ public static string Language { if (value == _curLanguage) return; _curLanguage = value; + EditorPrefs.SetString(EditorPrefKey, value); TriggerLanguageChangeCallbacks(); } }