简体   繁体   中英

ASP.NET CORE (.NET Framework) and Localization

people. All right?

Can someone help me? ASP.NET Core with .Net Framework

Subject: Localization

I made all the settings according to the documentation.

When I use:

IStringLocalizer<HomeController> 

works perfectly translation.

IStringLocalizer<Resources.Views.Shared.Test>

works perfectly translation.

in View

@inject IViewLocalizer localizer

works translated correctly.

However, in all previous cases, Resources were created in the ASP.NET CORE project.

If I create a separate project and use:

IStringLocalizer<ClassLibrary1.Test> 

does not work, it does not translate.

It returns only the default language.

If I force the code in ASP.NET Core of Controller:

ResourceManager rm = new ResourceManager(typeof(ClassLibrary1.Test));
string test = rm.GetString("Hello", new System.Globalization.CultureInfo("en-US"));

It does not translate well. It returns only the default language.

That is, I suspected it was related to being in a separate project.

Now the strange thing is that I created another ClassLibrary and put the code:

string test = Test.ResourceManager.GetString("Hello", new System.Globalization.CultureInfo("en-US"));

If I reference this ClassLibrary in a ASP.NET CORE, the return is the standard language, which is wrong.

If I reference in a Asp.Net, it works and translates perfectly.

This would be a known bug?

Some specific configuration for the class libraries in designs used in asp.net core?

I imagine the same code should work both in asp.net as the core asp.net with .NET framework.

Has anyone had a similar problem?

Problem solved.

It was identified that the resource DLLs are not copied to the ASP.NET Core projects.

Just manually copy after the build that everything is solved. It is the only solution for now.

Details here: https://github.com/aspnet/Mvc/issues/5219

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM