?
Solved

Identify installed Windows language in c# (asp.net)

Posted on 2007-10-17
8
Medium Priority
?
2,904 Views
Last Modified: 2008-01-09
Hey..  

I have some trouble identifying the installed language Windows use.
This is kinda what I have in mind:

if (Request.Browser.Browser == "IE")
        {
            if(installed language equals English)
            {
                lblLabel.Text = "blablabla in English";
            }

            if(installed language equals Danish)
            {
                lblLabel.Text = "blablabla in Danish";
            }
        }

(Sorry for the mix of code and pseudo code..)

In other words, if the browser is IE and the installed language of Windows is English, it should display some text, and the same if the system is Danish.

Is it possible?

Thanks in advance..
0
Comment
Question by:dennis_hs
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 5

Expert Comment

by:KPMT-Technician
ID: 20098831
Here are a few resources to help you.

Pre-written Javascript:
javascript.internet.com/user-details/user-language-and-country.html

Basic Javescript to check browser language:
navigator.language (Netscape - Browser Localization)
navigator.browserLanguage (IE-Specific - Browser Localized Language)
navigator.systemLanguage (IE-Specific - Windows OS - Localized Language)
navigator.userLanguage (IE-Specific - Windows OS - Regional Settings)
Found at; articles.techrepublic.com.com/5100-22-5069931.html

List of ISO 639 Language Codes to check:
www.w3.org/WAI/ER/IG/ert/iso639.htm

Robert Fidler
Springfield, Missouri
0
 
LVL 1

Author Comment

by:dennis_hs
ID: 20098943
There's no direct c# way?
0
 
LVL 7

Expert Comment

by:bungHoc
ID: 20099278
Hey Dennis,

From top of my head (sorry don't have running C# at the moment), but you can always use:
        // Get same culture as that set in Control Panel.
        culture = Thread.CurrentThread.CurrentCulture;

Hope it helps...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:dennis_hs
ID: 20118726
KPMT-Technician - Unfortunately "javascript.internet.com/user-details/user-language-and-country.html" is IE only.

bungHoc - I'm not quite sure how to use that  :(
0
 
LVL 5

Expert Comment

by:KPMT-Technician
ID: 20120750
This will work cross-browser and is in C#.

/// Code for getting languages
string[] languages = this.Request.UserLanguages;

Robert Fidler
Springfield, Missouri
0
 
LVL 7

Accepted Solution

by:
bungHoc earned 800 total points
ID: 20121189
KPMT-Technician,

string[] languages = this.Request.UserLanguages; -- will get you a string array of client language.


Dennis,

Refer to this article mate:
http://msdn2.microsoft.com/en-us/library/system.threading.thread.currentculture.aspx

By the way, sorry, the code I gave you only determines current language. Let's say my installed windows was Dutch. But I switched UI to English. So right now that piece of code only returns "en-US"
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20305251
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question