Skip to content

Microsoft.AspNetCore.Identity localize.Support zh-CN,en-US,de-DE,es-ES,fr-FR,pl-PL,pt-PT,ru-RU,tr-TR,uk-UA language

License

Notifications You must be signed in to change notification settings

JohnnyZhang0628/AspNetCore.Identity.Localization.Core

Repository files navigation

AspNetCore.Identity.Localization GitHub license NuGet downloads

Microsoft.AspNetCore.Identity localization.Support zh-CN,en-US,de-DE,es-ES,fr-FR,pl-PL,pt-PT,ru-RU,tr-TR,uk-UA language

Microsoft.AspNetCore.Identity是支持多种语言的语言包。

Install

Install-Package AspNetCore.Identity.Localization.Core

Use

1、using AspNetCore.Identity.Localization.Core;

2、update ConfigureServices method in Startup.cs file.

services.AddDbContext<AppDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("Identity")));

services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<AppDbContext>()
+ .AddIdentityErrorDescriber();

+ services.AddIdentityLocalization();

services.AddControllers();

3、update ConfigureServices method in Startup.cs file.

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

app.UseRouting();

+ // support language list.The web site default language is cultures[0]
+ var cultures = Configuration.GetSection("Cultures").Value.Split(",");
+ app.UseIdentityLocalization(cultures);

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
   endpoints.MapControllers();
});

4、update appsettings.json file.

"Cultures": "zh-CN,en-US,de-DE,es-ES,fr-FR,pl-PL,pt-PT,ru-RU,tr-TR,uk-UA"

test

1.git clone https://github.com/JohnnyZhang0628/AspNetCore.Identity.Localization.Core.git

  1. open WebIdentity.sln

  2. open http://localhost:54176/api/identity?culture=zh-cn in browser.

culture parameter in zh-CN,en-US,de-DE,es-ES,fr-FR,pl-PL,pt-PT,ru-RU,tr-TR,uk-UA

add other language

1.copy SharedResource.zh-CN.resx and rename SharedResource.other-other.resx.

2.add 'other-other' in Cultures value.

3.open http://localhost:54176/api/identity?culture=other-other in browser.

About

Microsoft.AspNetCore.Identity localize.Support zh-CN,en-US,de-DE,es-ES,fr-FR,pl-PL,pt-PT,ru-RU,tr-TR,uk-UA language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages