ResourceManagerWithCultureStringLocalizer class and WithCulture method removed in .NET 5.0

190 Views Asked by At

As per the documentation, the ResourceManagerWithCultureStringLocalizer class and WithCulture method were removed in .NET 5.0

https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/5.0/localization-members-removed

I need the ability to change the culture to send a bunch of emails, and can not rely on the applications culture.

Microsoft themselves do not offer any alternative for this. As per the documentation: "Recommended action Stop using the ResourceManagerWithCultureStringLocalizer class and the ResourceManagerStringLocalizer.WithCulture method."

Pretty helpful.

What's the best approach here to change the culture programatically without changing the applications culture everytime?

My pseudo code is:

IStringLocalizer<MyResourceFile> _localizer;
_localizer.WithCulture(new CultureInfo(1111))["myString"]
0

There are 0 best solutions below