public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var defaultLanguage = _cacheProvider.DefaultLanguage; var defaultLangueageResource = _cacheProvider.GetDefaultLanguageResourceList(); (_helper as IViewContextAware).Contextualize(ViewContext); output.TagName = ""; output.TagMode = TagMode.SelfClosing; var viewModel = new Dictionary <string, string>(); foreach (var resource in defaultLangueageResource) { if (viewModel.ContainsKey(resource.Key)) { continue; } if (defaultLanguage.CultureName != CultureInfo.CurrentUICulture.Name) { var localizer = _stringLocalizer[resource.Key]; viewModel.Add(localizer.Name, localizer.Value); } else { viewModel.Add(resource.Key, resource.Value); } } if (defaultLanguage.CultureName != CultureInfo.CurrentUICulture.Name) { var resources = _cacheProvider .GetResourceByLanguageCultureName(CultureInfo.CurrentUICulture.Name) .ToDictionary(k => k.Key, k => k.Value); viewModel.AddRangeNewOnly(resources); } var partialView = "~/Components/LanguageSelector/Views/_NetCoreStackLanguageJavaScriptRegistrar.cshtml"; var content = await _helper.PartialAsync(partialView, viewModel); output.Content.SetHtmlContent(content); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var resources = _cacheProvider.GetResourceByLanguageCultureName(CultureInfo.CurrentUICulture.Name); (_helper as IViewContextAware).Contextualize(ViewContext); output.TagName = ""; output.TagMode = TagMode.SelfClosing; var viewModel = new Dictionary <string, string>(); foreach (var resource in resources) { viewModel.Add(resource.Key, resource.Value); } var partialView = "~/Components/LanguageSelector/Views/_NetCoreStackLanguageJavaScriptRegistrar.cshtml"; var content = await _helper.PartialAsync(partialView, viewModel); output.Content.SetHtmlContent(content); }