Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

ASP.NET Core (.NET Framework) and Localization #5219

Closed
Tolitech opened this issue Sep 2, 2016 · 6 comments
Closed

ASP.NET Core (.NET Framework) and Localization #5219

Tolitech opened this issue Sep 2, 2016 · 6 comments
Assignees

Comments

@Tolitech
Copy link

Tolitech commented Sep 2, 2016

Hello...
This is a bug?
Thank you.

Why the libraries that I'm using in my ASP.NET Core project (.NET Framework) do not return messages translated as the selected culture?

For example:

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

This code is in a library part that has business rules and returns a message.

But when it is referenced in an ASP.NET MVC project it returns the message as the current culture (pt-br, en-us).

But if this library is referenced in a ASP.NET Core project (.NET Framework), nothing makes it return in the current culture.

ASP.NET
ResourceManager rm = new ResourceManager(typeof (ClassLibrary1.Test));
string test1 = rm.GetString("Hello", new System.Globalization.CultureInfo("en-US"));
string test2 = rm.GetString("Hello", new System.Globalization.CultureInfo("pt-BR"));

test1 = Message en-US
test2 = Message pt-BR

ASP.NET Core
ResourceManager rm = new ResourceManager(typeof(ClassLibrary1.Test));
string test1 = rm.GetString("Hello", new System.Globalization.CultureInfo("en-US"));
string test2 = rm.GetString("Hello", new System.Globalization.CultureInfo("pt-BR"));

test1 = Message pt-BR
test2 = Message pt-BR

Detail that everything is configured correctly on ASP.NET Core because:

IStringLocalizer<HomeController>
@inject IViewLocalizer localizer

It works perfectly.

The problem is in the Resources of the referenced libraries.

Can someone help me?

@pranavkm
Copy link
Contributor

pranavkm commented Sep 2, 2016

@ryanbrandenburg, is this the same issue as the one reported here - aspnet/Localization#277 (comment)?

@Tolitech
Copy link
Author

Tolitech commented Sep 2, 2016

No, I believe not.
They are different situations.
The error that occurs I commented in a separate library.

@ryanbrandenburg
Copy link
Member

I agree with @Tolitech that this is not a duplicate of aspnet/Localization#277. It does sound very similar to dotnet/aspnetcore#1707 and dotnet/cli#4153. @Tolitech is the class library you have csproj/xproj or project.json? I would guess from context that it's csproj and therefor likely a dup of dotnet/aspnetcore#1707, do you agree @Tolitech?

@Tolitech
Copy link
Author

Tolitech commented Sep 9, 2016

Hi, @ryanbrandenburg .
Yes, this is very similar to dotnet/aspnetcore#1707

I analyzed some problems here reported on Localization and most problems have the same solution as dotnet/cli#4153.

The resource files are not copied to the appropriate folders BIN on ASP.NET Core.
Just manually copy the dlls resource and perform refresh the page to solve the problem.

I tested several cases here and the manual copy of dlls is now working properly.

Thanks.

@Tolitech
Copy link
Author

Tolitech commented Sep 9, 2016

A note another problem: when we keep the name of the asp.net core folder different from .xproj project name is a problem that the internal resources (created within the core asp.net project) crash.

Example:
Presentation / ProjectName / ProjectName.xproj (Resources works)
Presentation / AnotherFolderName / ProjectName.xproj (Resources does not work)

@ryanbrandenburg
Copy link
Member

@Tolitech it sounds like this is a dup then, so I'll close it out.

As for your other problem that sounds like a separate (although tangentially related) issue, so please file a new issue for it against aspnet/Localization with more details about your folder structure, what exceptions/errors you get when experiencing the problem, etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants