Decouple StringLocalizer / HtmlLocalizer from types to make Shared Resources possible #153
Description
Hi
I had localization working perfectly with beta8 but in RC1 it is not working.
I have two resource files under Resources folder:
- Example.Resources.Example.Startup.en-AU.resx
- Example.Resources.Example.Startup.zh-CHS.resx
I also have the following resource related configured in Startup:
services.AddLocalization(l => l.ResourcesPath = "Resources");
...
var requestLocalizationOptions = new RequestLocalizationOptions
{
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("en-AU"),
new CultureInfo("zh-CHS")
},
SupportedUICultures = new List<CultureInfo>
{
new CultureInfo("en-AU"),
new CultureInfo("zh-CHS")
}
};
app.UseRequestLocalization(requestLocalizationOptions, new RequestCulture("en-AU"));
I only use IStringLocalizer<Startup>
injected into my views / controllers but it just show me the Key and not the Value even though my request header accept language is en-AU, however if I add a third resource file (Example.Resources.Example.Startup.resx) to Resources folder without the culture at the end it works by providing a Value instead of the Key.
I use the very odd weird pattern of having to have a class to use shared resources (shared resources across files types etc are the way it works in the real world), so I am forced to use Startup or create an EMPTY class! It seems that the designer of how the new localization works has never worked with multicultural applications...
Why not make it possible to pass in a resource name instead of making it type specific!? Really really odd and really limiting. I think there will be a lot of people complaining in the future when this is RTM!
Please guys test it and fix it!