I am attempting to dynamically set the language of an IStringLocalizer
at run time. The only available method that seems to do this is IStringLocalizer.WithCulture
. However, attempting to use it results in a deprecation warning.
public IStringLocalizer GetLocalizer(string locale) {
this.localizerFactory.Create(typeof(CommonResources)).WithCulture(new CultureInfo(locale));
}
I am not using ASP, I am doing this in an IHostedService
that handles user interaction from another source (various web chat APIs). This service needs to conform to the language set for the chat server or channel by the admins (stored in database).
What is the correct, current way of setting the language of an IStringLocalizer
? Should I use another class entirely?