diff --git a/Mutagen.Bethesda.Core.UnitTests/Strings/TranslatedStringTests.cs b/Mutagen.Bethesda.Core.UnitTests/Strings/TranslatedStringTests.cs index ae9cc694e8..f73240af87 100644 --- a/Mutagen.Bethesda.Core.UnitTests/Strings/TranslatedStringTests.cs +++ b/Mutagen.Bethesda.Core.UnitTests/Strings/TranslatedStringTests.cs @@ -336,6 +336,16 @@ public override TranslatedString Create(params KeyValuePair[] [Collection("TranslatedString")] public class TranslatedString_ByLookup : ATranslatedStringTests { + [Fact] + public void NumLanguagesReturnsMany() + { + TranslatedString.DefaultLanguage = Language.English; + ITranslatedString str = Create( + new KeyValuePair(Language.English, EnglishString), + new KeyValuePair(Language.French, FrenchString)); + str.NumLanguages.Should().Be(2); + } + public class ManualStringsLookup : IStringsFolderLookup { private readonly StringsSource _source; diff --git a/Mutagen.Bethesda.Core/Strings/TranslatedString.cs b/Mutagen.Bethesda.Core/Strings/TranslatedString.cs index 1c61cafc64..b59eb71965 100644 --- a/Mutagen.Bethesda.Core/Strings/TranslatedString.cs +++ b/Mutagen.Bethesda.Core/Strings/TranslatedString.cs @@ -68,7 +68,14 @@ public string? String set => Set(TargetLanguage, value); } - public int NumLanguages => _localization?.Count ?? 1; + public int NumLanguages + { + get + { + ResolveAllStringSources(); + return _localization?.Count ?? 1; + } + } private static TranslatedString _empty = new(Language.English, string.Empty); public static ITranslatedStringGetter Empty => _empty; @@ -273,7 +280,7 @@ internal void ResolveAllStringSources() } else { - _localization[lang] = null; + _localization.Remove(lang); } } StringsLookup = null;