When my project was using
<TargetFramework>netcoreapp3.1</TargetFramework>
I could get the localization injected in my page constructor:
IStringLocalizer<Strings> _localizer;
public IndexModel(IStringLocalizer<Strings> localizer) {
_localizer = localizer;
}
but still retrieve an alternative language's collection of strings:
var localizer = _localizer.WithCulture(new CultureInfo(cultureCode));
var translatedStr = localizer[c.Value].ToString();
Being in the process of upgrading to:
<TargetFramework>net6.0</TargetFramework>
The _localizer.WithCulture
code shows this error in VS Code:
'IStringLocalizer<Strings>' does not contain a definition for 'WithCulture' and no accessible extension method 'WithCulture' accepting a first argument of type 'IStringLocalizer<Strings>' could be found (are you missing a using directive or an assembly reference?)
What is the dotnet 6 version of this?
If I switch back to netcoreapp3.1
I can clearly see the warning:
'IStringLocalizer.WithCulture(CultureInfo)' is obsolete: 'This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.'
But what are the CurrentCulture
and CurrentUICulture
it is referring to?