Minor refactor.

pull/179/head
Halil İbrahim Kalkan 7 years ago
parent 5d67d427ca
commit 31fa23ccc8

@ -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

@ -27,5 +27,7 @@ namespace Volo.Abp.Localization
/// </summary>
/// <returns>List of all <see cref="LocalString"/> object</returns>
IReadOnlyList<LocalString> GetAllStrings();
void Extend(ILocalizationDictionary dictionary);
}
}

@ -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;
}
}
/// <inheritdoc/>
public virtual IEnumerator<LocalString> GetEnumerator()
{

@ -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);
}
}
}

Loading…
Cancel
Save