diff --git a/Projects/Server/Localization/Localization.cs b/Projects/Server/Localization/Localization.cs index ea0ef5bd8..f5440cb23 100644 --- a/Projects/Server/Localization/Localization.cs +++ b/Projects/Server/Localization/Localization.cs @@ -28,7 +28,7 @@ public static class Localization public const string FallbackLanguage = "enu"; private static Dictionary _fallbackEntries; - private static Dictionary> _localizations = new(); + private static readonly Dictionary> _localizations = new(); public static void Configure() { @@ -44,6 +44,7 @@ public static class Localization public static void Add(string lang, int number, string text) { + lang = lang.ToLower(); var entry = new LocalizationEntry(lang, number, text); if (!_localizations.TryGetValue(lang, out var entries)) { @@ -60,6 +61,7 @@ public static class Localization public static bool Remove(string lang, int number) { + lang = lang.ToLower(); if (!_localizations.TryGetValue(lang, out var entries) || !entries.Remove(number)) { return false; @@ -73,11 +75,18 @@ public static class Localization return true; } + public static void Clear() + { + _localizations.Clear(); + _fallbackEntries = null; + } + public static Dictionary LoadClilocs(string lang) => LoadClilocs(lang, Core.FindDataFile($"cliloc.{lang}", false)); private static Dictionary LoadClilocs(string lang, string file) { + lang = lang.ToLower(); Dictionary entries = _localizations[lang] = new Dictionary(); if (lang == FallbackLanguage) { @@ -145,6 +154,7 @@ public static class Localization /// True if the entry exists, otherwise false. public static bool TryGetLocalization(string lang, int number, out LocalizationEntry entry) { + lang = lang.ToLower(); if (lang != FallbackLanguage) { if (!_localizations.TryGetValue(lang, out var entries)) diff --git a/Projects/UOContent/Commands/ResetLocalization.cs b/Projects/UOContent/Commands/ResetLocalization.cs new file mode 100644 index 000000000..1d567d48c --- /dev/null +++ b/Projects/UOContent/Commands/ResetLocalization.cs @@ -0,0 +1,20 @@ +namespace Server.Commands; + +public static class ResetLocalization +{ + public static void Configure() + { + CommandSystem.Register("ResetLocalization", AccessLevel.Developer, ResetLocalization_OnCommand); + } + + [Usage("ResetLocalization []")] + [Aliases("ResetLoc")] + [Description( + "Clears the localization table. Cliloc will be reloaded the next time they are used for that language." + )] + private static void ResetLocalization_OnCommand(CommandEventArgs e) + { + Localization.Clear(); + e.Mobile.SendMessage("Localization table cleared."); + } +} diff --git a/docs/commands/commands.7z b/docs/commands/commands.7z index a7067618d..cf5b93cc6 100644 Binary files a/docs/commands/commands.7z and b/docs/commands/commands.7z differ