什么是dotnet 6等于interiber.tresculture。

发布于 2025-02-10 02:11:17 字数 1244 浏览 2 评论 0原文

当我的项目使用时,

<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.'

但是CurrentultureCurrentUIculture它是什么?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文