Convert browser language eg. en-us to country code eg. en RRS feed

  • Question

  • User1473179044 posted


    I am working on a client language sniffer. It looks up the users language by IP and also looks a the clients browser language.

    My problem now is that the browser language is formatted differently from that of the IP lookup software I am using (MaxMind GeoLite Country). I am located in Denmark and the IP lookup returns DK which is the country code. That's fine depending on the browser it might return da-DK, DK or DA.

    Has anyone come across a component to convert the language code / regional code into the country code?

    Friday, October 23, 2009 9:12 AM

All replies

  • User1577733570 posted


    Please refer this-


    Hope this will help you. 

    Thursday, October 29, 2009 2:50 AM
  • User1473179044 posted

    Thanks for the link but it doesn't really have the conversion I am out after.

    Thursday, October 29, 2009 6:06 AM
  • User1577733570 posted


    As per my understanding your query is how to change language/ region code to country code. To do so we can user RegionInfo class.

    Here is code for the same-

    RegionInfo myRI2 = new RegionInfo(new CultureInfo("en-US", false).LCID);

    string str=myRI2.Name;

    Here str will return US as country code.

    Hope this will solve your query :)

    Thursday, October 29, 2009 11:44 PM
  • User1473179044 posted

    Hi again,

    Thanks maybe I was a bit to hasty reading up on it. That looks like it might do the trick : )

    Friday, October 30, 2009 3:33 AM