diff --git a/CHANGELOG.md b/CHANGELOG.md index 87506628..0f18153f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Fixed +- Fix language code not recognizable due to inconsistent case ### Changed diff --git a/Editor/UI/Localization/Localizer.cs b/Editor/UI/Localization/Localizer.cs index 1fd6b08a..9e8c8b09 100644 --- a/Editor/UI/Localization/Localizer.cs +++ b/Editor/UI/Localization/Localizer.cs @@ -71,7 +71,7 @@ public Localizer(string defaultLanguage, Func> assetLoad })).ToList(); }; - languages = ImmutableSortedDictionary>.Empty; + languages = ImmutableSortedDictionary>.Empty.WithComparers(StringComparer.OrdinalIgnoreCase); LoadLocalizations(); _reloadLocalizations += LoadLocalizations; } @@ -88,7 +88,7 @@ void LoadLocalizations() if (_localizationLoader == null) return; - var newLanguages = ImmutableSortedDictionary>.Empty; + var newLanguages = ImmutableSortedDictionary>.Empty.WithComparers(StringComparer.OrdinalIgnoreCase); foreach (var (lang, lookup) in _localizationLoader()) { var normalizedLang = CultureInfo.GetCultureInfo(lang).Name; @@ -129,10 +129,10 @@ public bool TryGetLocalizedString(string key, out string value) .Select(l => languages[l]) .ToList(); - if (languages.ContainsKey(LanguagePrefs.Language)) + if (languages.TryGetValue(LanguagePrefs.Language, out var currentLookup)) { // Always try the exact match first - lookups.Insert(0, languages[LanguagePrefs.Language]); + lookups.Insert(0, currentLookup); } _lookupCache = k =>