I created an MVC web application using asp.net and visual studio 2012.
Now, I want to make it multilangual. Depending on the browsers language of the user, to open the page in one language or an other automatically.
I was searching on the internet and I create two global resources called:
ContentEN.resx
ContentES.resx
In both files I added some values with the same key and different value for example:
Name: userInformation, value: User information Name: userInformation, value: Informacion de usuario
Then on the HTML Im able to use the label like @Resources.ContentES.UserInformation
The problem is that I want to do it automatically. So the question is: once I create both files for both languages, how can I do use one or the other depending of the user's browser?
Thanks!
You need to name your resources differently:
Content.resx
Content.EN.resx
Content.ES.resx
Where Content.resx is the default fallback. And then request them like this:
@Resources.Content.UserInformation
But this only works if your thread language is set accordingly.
https://weblog.west-wind.com/posts/2014/Mar/27/Auto-Selecting-Cultures-for-Localization-in-ASPNET
The main point is this:
<system.web>
<globalization culture="auto:en-US" uiCulture="fr" />
</system.web>