From 7973e44fd7189ad05187b8ea766993a6d6737b3e Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 26 Mar 2024 23:16:51 +0900 Subject: [PATCH] fix: default Language contains upper case (#215) * fix: default Language contains upper case * sanitaize language code before set * chore: fix language value if it's non-lowercase in EditorPrefs * chore: update CHANGELOG --------- Co-authored-by: bd_ --- CHANGELOG.md | 1 + Editor/UI/Localization/LanguagePrefs.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d23e0e6..aa9efb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Specify zh-* font to make the font normal +- Fixed issues with capitalization in language preference (#215) ### Changed - In ParameterProvider, the parameter type of PhysBone Contact Receiver is now the type corresponding to the receiver type. (#209) diff --git a/Editor/UI/Localization/LanguagePrefs.cs b/Editor/UI/Localization/LanguagePrefs.cs index 051d8a0..7344e19 100644 --- a/Editor/UI/Localization/LanguagePrefs.cs +++ b/Editor/UI/Localization/LanguagePrefs.cs @@ -34,7 +34,7 @@ public static class LanguagePrefs private static void Init() { // Exiting playmode destroys the dynamic font assets we create, so we need to recreate and reapply them. - Language = EditorPrefs.GetString(EditorPrefKey, "en-US"); + Language = EditorPrefs.GetString(EditorPrefKey, "en-us").ToLowerInvariant(); EditorApplication.playModeStateChanged += evt => { foreach (var fontCallback in _fontUpdateCallbacks.Values) @@ -52,6 +52,7 @@ public static string Language get => _curLanguage; set { + value = value.ToLowerInvariant(); if (value == _curLanguage) return; _curLanguage = value; EditorPrefs.SetString(EditorPrefKey, value); @@ -307,4 +308,4 @@ public static void ApplyFontPreferences(VisualElement elem) { } #endif } -} \ No newline at end of file +}