public async Task <string> Execute(string resource, string culture) { if (string.IsNullOrEmpty(culture)) { culture = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag; } var res = resource.Split('|'); var reourceName = res[0]; var reourceKey = res[1]; var langRes = await _dbContext .Set <LangResourceValue>() .Where(c => c.LangResource.Name == reourceName && c.LangResource.Culture.Key == culture && c.Key == reourceKey) .FirstOrDefaultAsync(); if (langRes == null) { var dictionary = LangResourceDefaults.Get(reourceName, culture); return(dictionary[reourceKey]); } return(langRes.Value); }
public async Task <Dictionary <string, string> > Execute(string resource, string culture) { if (culture == null) { culture = Thread.CurrentThread.CurrentUICulture.IetfLanguageTag; } var langRes = await _dbContext .Set <LangResourceValue>() .Where(c => c.LangResource.Name == resource && c.LangResource.Culture.Key == culture) .ToDictionaryAsync(r => r.Key, r => r.Value); var defaults = LangResourceDefaults.Get(resource, culture); foreach (var d in defaults) { if (!langRes.ContainsKey(d.Key)) { langRes.Add(d.Key, d.Value); } } return(langRes); }