user display language

  • Thread starter Thread starter Loui Mercieca
  • Start date Start date
L

Loui Mercieca

I am tying to retrieve the user's default language to display the resources
according to the language. For example, if the user is from germany, i will
display the german resources without asking him having to log in first.

Can anyone help me or just point me to the right direction.
 
I am tying to retrieve the user's default language to display the resources
according to the language. For example, if the user is from germany, i will
display the german resources without asking him having to log in first.
The following code will list the users preferred languages in descending
order.

int count;
string[] languages= Request.UserLanguages;

for (count = 0; count < languages.Length; count++) {
Response.Write("Language " + count +": " + languages[count] + "<br>");
}

The language preference is retrieved from the browser. In Internet Explorer
you can set language preferences in the Tools -> Internet Options ->
Languages dialog.

Please note that the language settings reflect which languages the user
preferes, not the country he or she resides in.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
Loui,

You can determine a users culture by including the System.Globalization
namespace and calling the CultureInfo.CurrentCulture.Name property.
This can be used along with the ResourceManager to determine everything that
you will need to Globalize/localize your application. For more information
please see the topic "Developing World-Ready Applications" in the MSDN.

Hope that this helps!
 
Back
Top