diff --git a/src/Volo.Abp/Volo/Abp/Localization/AbpStringLocalizerFactory.cs b/src/Volo.Abp/Volo/Abp/Localization/AbpStringLocalizerFactory.cs index 932b8fca76..96c45777df 100644 --- a/src/Volo.Abp/Volo/Abp/Localization/AbpStringLocalizerFactory.cs +++ b/src/Volo.Abp/Volo/Abp/Localization/AbpStringLocalizerFactory.cs @@ -48,9 +48,10 @@ namespace Volo.Abp.Localization //Notes: Localizer will be cached, so wrappers are responsible to cache/invalidate themselves! - var baseLocalizers = resource.BaseResourceTypes.Select(Create).ToList(); - - var localizer = new AbpDictionaryBasedStringLocalizer(resource, baseLocalizers); + var localizer = new AbpDictionaryBasedStringLocalizer( + resource, + resource.BaseResourceTypes.Select(Create).ToList() + ); //TODO: Wrap with DB provider or other premium sources diff --git a/src/Volo.Abp/Volo/Abp/Localization/ILocalizationDictionary.cs b/src/Volo.Abp/Volo/Abp/Localization/ILocalizationDictionary.cs index 8563400781..4f0b980428 100644 --- a/src/Volo.Abp/Volo/Abp/Localization/ILocalizationDictionary.cs +++ b/src/Volo.Abp/Volo/Abp/Localization/ILocalizationDictionary.cs @@ -27,5 +27,7 @@ namespace Volo.Abp.Localization /// /// List of all object IReadOnlyList GetAllStrings(); + + void Extend(ILocalizationDictionary dictionary); } } \ No newline at end of file diff --git a/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionary.cs b/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionary.cs index 700633ce22..dbf5abec5e 100644 --- a/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionary.cs +++ b/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionary.cs @@ -43,6 +43,14 @@ namespace Volo.Abp.Localization return _dictionary.Values.ToImmutableList(); } + public void Extend(ILocalizationDictionary dictionary) + { + foreach (var localizedString in dictionary.GetAllStrings()) + { + this[localizedString.Name] = localizedString; + } + } + /// public virtual IEnumerator GetEnumerator() { diff --git a/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionaryProviderBase.cs b/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionaryProviderBase.cs index f07f962e57..991feb9c48 100644 --- a/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionaryProviderBase.cs +++ b/src/Volo.Abp/Volo/Abp/Localization/LocalizationDictionaryProviderBase.cs @@ -34,15 +34,7 @@ namespace Volo.Abp.Localization } else { - Overwrite(existingDictionary, dictionary); - } - } - - protected virtual void Overwrite(ILocalizationDictionary existingDictionary, ILocalizationDictionary dictionary) - { - foreach (var localizedString in dictionary.GetAllStrings()) - { - existingDictionary[localizedString.Name] = localizedString; + existingDictionary.Extend(dictionary); } } }