Skip to content

Commit

Permalink
fix: default Language contains upper case (#215)
Browse files Browse the repository at this point in the history
* 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_ <[email protected]>
  • Loading branch information
anatawa12 and bdunderscore authored Mar 26, 2024
1 parent 79e7f08 commit 7973e44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions Editor/UI/Localization/LanguagePrefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -52,6 +52,7 @@ public static string Language
get => _curLanguage;
set
{
value = value.ToLowerInvariant();
if (value == _curLanguage) return;
_curLanguage = value;
EditorPrefs.SetString(EditorPrefKey, value);
Expand Down Expand Up @@ -307,4 +308,4 @@ public static void ApplyFontPreferences(VisualElement elem) {
}
#endif
}
}
}

0 comments on commit 7973e44

Please sign in to comment.