4

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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

Burned several hours on this. I can confirm this is correct. Unfortunate (on Microsofts End) but correct. Just copy the culture folder that's generated in the project that contains the resources into the output directory of the Core project and ResourceManager will start working normally again. (e.g the "en-US" folder to "bin\net452"...bam...done deal). Thanks Edwardo for sorting this one out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.