|
|
@ -31,7 +31,7 @@ namespace LINGYUN.Abp.LocalizationManagement |
|
|
ResourceRepository = resourceRepository; |
|
|
ResourceRepository = resourceRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<List<LanguageInfo>> GetLanguageListAsync( |
|
|
public async virtual Task<List<LanguageInfo>> GetLanguageListAsync( |
|
|
CancellationToken cancellationToken = default) |
|
|
CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
var languages = await LanguageRepository.GetActivedListAsync(cancellationToken); |
|
|
var languages = await LanguageRepository.GetActivedListAsync(cancellationToken); |
|
|
@ -41,7 +41,7 @@ namespace LINGYUN.Abp.LocalizationManagement |
|
|
.ToList(); |
|
|
.ToList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<Dictionary<string, ILocalizationDictionary>> GetLocalizationDictionaryAsync( |
|
|
public async virtual Task<Dictionary<string, ILocalizationDictionary>> GetLocalizationDictionaryAsync( |
|
|
string resourceName, |
|
|
string resourceName, |
|
|
CancellationToken cancellationToken = default) |
|
|
CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
@ -78,7 +78,40 @@ namespace LINGYUN.Abp.LocalizationManagement |
|
|
return dictionaries; |
|
|
return dictionaries; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<bool> ResourceExistsAsync(string resourceName, CancellationToken cancellationToken = default) |
|
|
public async virtual Task<Dictionary<string, Dictionary<string, ILocalizationDictionary>>> GetAllLocalizationDictionaryAsync(CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
var result = new Dictionary<string, Dictionary<string, ILocalizationDictionary>>(); |
|
|
|
|
|
var textList = await TextRepository.GetListAsync(resourceName: null, cancellationToken: cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var resourcesGroup in textList.GroupBy(x => x.ResourceName)) |
|
|
|
|
|
{ |
|
|
|
|
|
var dictionaries = new Dictionary<string, ILocalizationDictionary>(); |
|
|
|
|
|
foreach (var textGroup in resourcesGroup.GroupBy(x => x.CultureName)) |
|
|
|
|
|
{ |
|
|
|
|
|
var cultureTextDictionaires = new Dictionary<string, LocalizedString>(); |
|
|
|
|
|
foreach (var text in textGroup) |
|
|
|
|
|
{ |
|
|
|
|
|
// 本地化名称去重
|
|
|
|
|
|
if (!cultureTextDictionaires.ContainsKey(text.Key)) |
|
|
|
|
|
{ |
|
|
|
|
|
cultureTextDictionaires[text.Key] = new LocalizedString(text.Key, text.Value.NormalizeLineEndings()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 本地化语言去重
|
|
|
|
|
|
if (!dictionaries.ContainsKey(textGroup.Key)) |
|
|
|
|
|
{ |
|
|
|
|
|
dictionaries[textGroup.Key] = new StaticLocalizationDictionary(textGroup.Key, cultureTextDictionaires); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result.Add(resourcesGroup.Key, dictionaries); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async virtual Task<bool> ResourceExistsAsync(string resourceName, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await ResourceRepository.ExistsAsync(resourceName, cancellationToken); |
|
|
return await ResourceRepository.ExistsAsync(resourceName, cancellationToken); |
|
|
} |
|
|
} |
|
|
|