diff --git a/UXAssist/Common/I18N.cs b/UXAssist/Common/I18N.cs index a237470..548e0bf 100644 --- a/UXAssist/Common/I18N.cs +++ b/UXAssist/Common/I18N.cs @@ -13,7 +13,7 @@ public static class I18N private static bool _dirty; /// - /// Invoked after the game has finished loading the active language and all registered strings have been applied. + /// Invoked whenever the active language is applied or changed and all registered strings have been applied. /// public static Action OnInitialized; @@ -52,12 +52,14 @@ public static class I18N /// Registers a localized string pair. /// /// The lookup key. - /// The English text. - /// The Simplified Chinese text. - public static void Add(string key, string en, string zh) + /// The English text. + /// The Simplified Chinese text. + public static void Add(string key, string enus, string zhcn = null) { - if (zh is null && key == en) return; - Entries[key] = new LocalizedString(en, string.IsNullOrEmpty(zh) ? en : zh); + // Skip identity fallback entries: if no Chinese translation is provided and the key equals the English text, + // there is no need to register a separate entry because the key already serves as the fallback text. + if (zhcn is null && key == enus) return; + Entries[key] = new LocalizedString(enus, string.IsNullOrEmpty(zhcn) ? enus : zhcn); _dirty = true; } @@ -133,7 +135,7 @@ public static class I18N /// /// The lookup key. /// The localized text, or if no entry exists. - public static string Translate(string key) + internal static string Translate(string key) { if (!Entries.TryGetValue(key, out var loc)) return key; var languageIndex = Localization.currentLanguageIndex;