什么是dotnet 6等于interiber.tresculture。
当我的项目使用时,
<TargetFramework>netcoreapp3.1</TargetFramework>
我可以将本地化注入我的页面构造函数:
IStringLocalizer<Strings> _localizer;
public IndexModel(IStringLocalizer<Strings> localizer) {
_localizer = localizer;
}
但是仍然检索替代语言的字符串集合:
var localizer = _localizer.WithCulture(new CultureInfo(cultureCode));
var translatedStr = localizer[c.Value].ToString();
正在升级到:
<TargetFramework>net6.0</TargetFramework>
_localizer.withculture.withculture
代码>代码在VS代码:
'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?)
其中的Dotnet 6版本是什么?
如果我切换回netCoreapp3.1
我可以清楚地看到警告:
'IStringLocalizer.WithCulture(CultureInfo)' is obsolete: 'This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.'
但是Currentulture
和CurrentUIculture
它是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论