【问题标题】:Sample or tutorial to use Microsoft.AspNet.Identity.Core.<culture> for Identity Localization?使用 Microsoft.AspNet.Identity.Core.<culture> 进行身份本地化的示例或教程?
【发布时间】:2020-07-06 10:32:33
【问题描述】:

我需要本地化(意大利语)我搭建的身份/帐户区域的所有页面(我启动了没有身份验证的 asp.net 3.1 核心项目,然后使用添加新的脚手架项目添加了下面的页面...... )

我发现每种文化都有一个 Microsoft.AspNet.Identity.Core 程序集。 (例如Microsoft.AspNet.Identity.Core.it),但我不明白如何使用。

  1. 我尝试加载和引用它,但没有任何变化...您有示例如何使用吗?
  2. 是否只有在我使用“隐藏”模式时才可用(例如,使用身份验证个人用户帐户创建 asp.net 3.1 项目)?

谢谢 桑德罗

\Areas\Identity\Pages\Account\AccessDenied.cshtml.cs
\Areas\Identity\Pages\Account\ConfirmEmail.cshtml.cs
\Areas\Identity\Pages\Account\ConfirmEmailChange.cshtml.cs
\Areas\Identity\Pages\Account\ExternalLogin.cshtml.cs
\Areas\Identity\Pages\Account\ForgotPassword.cshtml.cs
\Areas\Identity\Pages\Account\ForgotPasswordConfirmation.cshtml.cs
\Areas\Identity\Pages\Account\Lockout.cshtml.cs
\Areas\Identity\Pages\Account\Login.cshtml.cs
\Areas\Identity\Pages\Account\LoginWith2fa.cshtml.cs
\Areas\Identity\Pages\Account\LoginWithRecoveryCode.cshtml.cs
\Areas\Identity\Pages\Account\Logout.cshtml.cs
\Areas\Identity\Pages\Account\Register.cshtml.cs
\Areas\Identity\Pages\Account\RegisterConfirmation.cshtml.cs
\Areas\Identity\Pages\Account\ResendEmailConfirmation.cshtml.cs
\Areas\Identity\Pages\Account\ResetPassword.cshtml.cs
\Areas\Identity\Pages\Account\ResetPasswordConfirmation.cshtml.cs
\Areas\Identity\Pages\Account\Manage\ChangePassword.cshtml.cs
\Areas\Identity\Pages\Account\Manage\DeletePersonalData.cshtml.cs
\Areas\Identity\Pages\Account\Manage\Disable2fa.cshtml.cs
\Areas\Identity\Pages\Account\Manage\DownloadPersonalData.cshtml.cs
\Areas\Identity\Pages\Account\Manage\Email.cshtml.cs
\Areas\Identity\Pages\Account\Manage\EnableAuthenticator.cshtml.cs
\Areas\Identity\Pages\Account\Manage\ExternalLogins.cshtml.cs
\Areas\Identity\Pages\Account\Manage\GenerateRecoveryCodes.cshtml.cs
\Areas\Identity\Pages\Account\Manage\Index.cshtml.cs
\Areas\Identity\Pages\Account\Manage\ManageNavPages.cs
\Areas\Identity\Pages\Account\Manage\PersonalData.cshtml.cs
\Areas\Identity\Pages\Account\Manage\ResetAuthenticator.cshtml.cs
\Areas\Identity\Pages\Account\Manage\SetPassword.cshtml.cs
\Areas\Identity\Pages\Account\Manage\ShowRecoveryCodes.cshtml.cs
\Areas\Identity\Pages\Account\Manage\TwoFactorAuthentication.cshtml.cs
``

【问题讨论】:

  • 有什么更新吗?我的回复能解决你的问题吗?

标签: asp.net-core asp.net-identity


【解决方案1】:

我尝试加载和引用它,但没有任何变化...您有示例如何使用吗? 是否只有在我使用“隐藏”模式时才可用(例如,使用身份验证个人用户帐户创建 asp.net 3.1 项目)?

据我所知,Microsoft.AspNet.Identity.Core 用于 ASP.NET 而不是 ASP.NET Core。 asp.net 核心标识包是Microsoft.AspNetCore.Identity。在 asp.net core 中使用 asp.net 身份并不简单。

如果您想使用 Localization for asp.net core 标识,您应该具备 Localization for asp.net core 的基本知识。请参考此article。您应该知道什么是资源文件,并知道它在 asp.net core 中如何为不同的文化生成不同的语言。

然后你可以参考这个example project,它已经为asp.net核心身份启用了本地化。

您可以直接 Fork repro,为您要翻译的语言创建资源文件,将新语言添加到 Startup.cs 中 zu-ZA 之前的supportedCultures 列表中并拉取请求进行测试。

注意:此示例项目是 2.2。如果您想使用 3.1,您可以按照示例项目为 3.1 项目创建本地化。

【讨论】:

  • 感谢您指出错误的框架(不是核心)。并感谢您的示例项目。我想我会直接用意大利语翻译脚手架的页面(因为在这个特定的项目中我迫切需要这种文化),但正确的方法是再次将 fork 适配为 3.1 thx
  • 如果您觉得我的回复对您有帮助,请标记为回答。以便其他人更容易找到正确的答复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-13
  • 1970-01-01
  • 2016-08-04
  • 2017-05-20
  • 2012-02-24
  • 2016-07-01
相关资源
最近更新 更多