Skip to content

Commit

Permalink
fix: language selection is not preserved over domain reload
Browse files Browse the repository at this point in the history
Fixes: #102
  • Loading branch information
bdunderscore committed Jan 6, 2024
1 parent 9910abd commit 775241f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Editor/UI/Localization/LanguagePrefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,8 +12,15 @@ namespace nadena.dev.ndmf.localization
/// </summary>
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");
}

/// <summary>
/// The currently selected language ID, e.g. "en-us".
/// </summary>
Expand All @@ -23,6 +31,7 @@ public static string Language
{
if (value == _curLanguage) return;
_curLanguage = value;
EditorPrefs.SetString(EditorPrefKey, value);
TriggerLanguageChangeCallbacks();
}
}
Expand Down

0 comments on commit 775241f

Please sign in to comment.