Having a Central location for all of your localization, be it browsing or data, is the best approach I can think of, and this is how I should work. In the Startup.cs file after installing the nuget packages for localization, add the following code
services.AddMvc().AddViewLocalization().AddDataAnnotationsLocalization(options => options.DataAnnotationLocalizerProvider = (type, factory) => new StringLocalizer<Resources>(factory)); services.Configure<RequestLocalizationOptions>(options => { var cultures = new[] { new CultureInfo("en"), new CultureInfo("ar") }; options.DefaultRequestCulture = new RequestCulture("en", "en"); options.SupportedCultures = cultures; options.SupportedUICultures = cultures; });
Therefore, the DataAnnotationLocalizerProvider will be from Resources. {culture} .rex - (The resource file must have an access modifier No gen code ) - provided that the default language does not require any resources, and also have access to the resource file, since the code will not be created and must be created empty class with the same name.
and in _ViewImports.cshtml enter the following
@inject IHtmlLocalizer<Resources> Localizer
Having done this, you now have the global Localizer variable that will be used in any of the views for localization purposes.

You can find more information about Globalization and Localization in ASP.NET Core
source share