diff --git a/Projects/Server.Tests/Tests/Localization/LocalizationEntryTests.cs b/Projects/Server.Tests/Tests/Localization/LocalizationEntryTests.cs index 154cfe7a6..a240a0576 100644 --- a/Projects/Server.Tests/Tests/Localization/LocalizationEntryTests.cs +++ b/Projects/Server.Tests/Tests/Localization/LocalizationEntryTests.cs @@ -17,4 +17,27 @@ public class LocalizationEntryTests Assert.Equal("This tests clilocs as parameters.", numericFormatter); Assert.Equal("This tests clilocs as parameters.", stringParam); } + + [Fact] + public void RemovingTheLastFallbackEntry_KeepsLaterAddsVisible() + { + Localization.Clear(); + + try + { + Localization.Add("enu", 500004, "first"); + Assert.True(Localization.Remove("enu", 500004)); + + Localization.Add("enu", 500005, "second"); + + Assert.False(Localization.TryGetLocalization(500004, out _)); + Assert.True(Localization.TryGetLocalization(500005, out var entry)); + Assert.Equal("second", entry.Text); + } + finally + { + // Lets the next lookup reload the real tables from disk. + Localization.Clear(); + } + } } diff --git a/Projects/Server/Localization/Localization.cs b/Projects/Server/Localization/Localization.cs index 21dbe801f..0b0bde43c 100644 --- a/Projects/Server/Localization/Localization.cs +++ b/Projects/Server/Localization/Localization.cs @@ -68,7 +68,9 @@ public static class Localization return false; } - if (entries.Count == 0) + // The fallback table stays registered even when empty: _fallbackEntries points at it, and a + // replacement created by a later Add would be invisible to fallback lookups. + if (entries.Count == 0 && entries != _fallbackEntries) { _localizations.Remove(lang); }