Get Culture Info from Language Name

Discussion in 'ASP .Net' started by lucky, Jan 31, 2007.

  1. lucky

    lucky Guest

    hi guys,
    right now i'm going through System.Globalization Namespace. and i
    found very intersting class there called CultureInfo.

    i was trying to get cultureInfo on the basis of name but i didnt find
    the way to do it. for example, if i pass the language name
    "Danish","German",Russian", i'm suppose to get the cultureInfo object
    of the language.

    can anyone help me out here?
    i would appriciate any help.

    thanks,
    Lucky
    lucky, Jan 31, 2007
    #1
    1. Advertising

  2. You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    following link shows the complete list:
    http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx

    Regards, Jakob.
    --
    http://www.dotninjas.dk



    "lucky" wrote:

    > hi guys,
    > right now i'm going through System.Globalization Namespace. and i
    > found very intersting class there called CultureInfo.
    >
    > i was trying to get cultureInfo on the basis of name but i didnt find
    > the way to do it. for example, if i pass the language name
    > "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > of the language.
    >
    > can anyone help me out here?
    > i would appriciate any help.
    >
    > thanks,
    > Lucky
    >
    >
    =?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=, Jan 31, 2007
    #2
    1. Advertising

  3. Hi,

    "NL-nl" Holland
    "NL-be" Belgium
    "EN-uk" Greath Brittain

    is this what you mean?

    Cor

    "lucky" <> schreef in bericht
    news:...
    > hi guys,
    > right now i'm going through System.Globalization Namespace. and i
    > found very intersting class there called CultureInfo.
    >
    > i was trying to get cultureInfo on the basis of name but i didnt find
    > the way to do it. for example, if i pass the language name
    > "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > of the language.
    >
    > can anyone help me out here?
    > i would appriciate any help.
    >
    > thanks,
    > Lucky
    >
    Cor Ligthert \(MVP\), Jan 31, 2007
    #3
  4. lucky

    rossum Guest

    On 31 Jan 2007 03:29:07 -0800, "lucky" <>
    wrote:

    >hi guys,
    >right now i'm going through System.Globalization Namespace. and i
    >found very intersting class there called CultureInfo.
    >
    >i was trying to get cultureInfo on the basis of name but i didnt find
    >the way to do it. for example, if i pass the language name
    >"Danish","German",Russian", i'm suppose to get the cultureInfo object
    >of the language.
    >
    >can anyone help me out here?
    >i would appriciate any help.
    >
    >thanks,
    >Lucky

    There is a full set of "Culture Names and Identifiers" in .NET, they
    are shown if you search the internal Help for the CultureInfo class.

    "The culture names follow the RFC 1766 standard in the format
    "<languagecode2>-<country/regioncode2>", where <languagecode2> is a
    lowercase two-letter code derived from ISO 639-1 and
    <country/regioncode2> is an uppercase two-letter code derived from ISO
    3166. For example, U.S. English is "en-US". In cases where a
    two-letter language code is not available, the three-letter code
    derived from ISO 639-2 is used; for example, the three-letter code
    "div" is used for cultures that use the Dhivehi language. Some culture
    names have suffixes that specify the script; for example, "-Cyrl"
    specifies the Cyrillic script, "-Latn" specifies the Latin script."

    Remember that what you program sees initially might not be "German"
    but "Deutsch" and that "Russian" could well be in Cyrillic characters.
    In general this is not a simple problem.

    rossum
    rossum, Jan 31, 2007
    #4
  5. "lucky" <> wrote in message
    news:...
    > hi guys,
    > right now i'm going through System.Globalization Namespace. and i
    > found very intersting class there called CultureInfo.
    >
    > i was trying to get cultureInfo on the basis of name but i didnt find
    > the way to do it. for example, if i pass the language name
    > "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > of the language.
    >


    foreach ( CultureInfo ci in
    CultureInfo.GetCultures(CultureTypes.NeutralCultures) ) {

    if (ci.EnglishName == "Danish") {

    ....

    }

    }
    Alexey Smirnov, Jan 31, 2007
    #5
  6. Or, you could simply use these :

    CultureInfo.CurrentCulture.EnglishName
    CultureInfo.CurrentCulture.DisplayName
    CultureInfo.CurrentCulture.NativeName




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Jakob Christensen" <> wrote in message
    news:...
    > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    > following link shows the complete list:
    > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    >
    > Regards, Jakob.
    > --
    > http://www.dotninjas.dk
    >
    >
    >
    > "lucky" wrote:
    >
    >> hi guys,
    >> right now i'm going through System.Globalization Namespace. and i
    >> found very intersting class there called CultureInfo.
    >>
    >> i was trying to get cultureInfo on the basis of name but i didnt find
    >> the way to do it. for example, if i pass the language name
    >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    >> of the language.
    >>
    >> can anyone help me out here?
    >> i would appriciate any help.
    >>
    >> thanks,
    >> Lucky
    >>
    >>
    Juan T. Llibre, Jan 31, 2007
    #6
  7. The OP wants to create a new CultureInfo from EnglishName which can not be
    done easily. I do not think that CurrentCulture is of much use here.

    :) Jakob.



    "Juan T. Llibre" wrote:

    > Or, you could simply use these :
    >
    > CultureInfo.CurrentCulture.EnglishName
    > CultureInfo.CurrentCulture.DisplayName
    > CultureInfo.CurrentCulture.NativeName
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "Jakob Christensen" <> wrote in message
    > news:...
    > > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    > > following link shows the complete list:
    > > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    > >
    > > Regards, Jakob.
    > > --
    > > http://www.dotninjas.dk
    > >
    > >
    > >
    > > "lucky" wrote:
    > >
    > >> hi guys,
    > >> right now i'm going through System.Globalization Namespace. and i
    > >> found very intersting class there called CultureInfo.
    > >>
    > >> i was trying to get cultureInfo on the basis of name but i didnt find
    > >> the way to do it. for example, if i pass the language name
    > >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > >> of the language.
    > >>
    > >> can anyone help me out here?
    > >> i would appriciate any help.
    > >>
    > >> thanks,
    > >> Lucky
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=, Jan 31, 2007
    #7
  8. re:
    > create a new CultureInfo from EnglishName which can not be done easily


    Aw, that's not so hard to do :

    http://asp.net.do/test/culture3.aspx



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Jakob Christensen" <> wrote in message
    news:...
    > The OP wants to create a new CultureInfo from EnglishName which can not be
    > done easily. I do not think that CurrentCulture is of much use here.
    >
    > :) Jakob.
    >
    >
    >
    > "Juan T. Llibre" wrote:
    >
    >> Or, you could simply use these :
    >>
    >> CultureInfo.CurrentCulture.EnglishName
    >> CultureInfo.CurrentCulture.DisplayName
    >> CultureInfo.CurrentCulture.NativeName
    >>
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> asp.net faq : http://asp.net.do/faq/
    >> foros de asp.net, en español : http://asp.net.do/foros/
    >> ===================================
    >> "Jakob Christensen" <> wrote in message
    >> news:...
    >> > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    >> > following link shows the complete list:
    >> > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    >> >
    >> > Regards, Jakob.
    >> > --
    >> > http://www.dotninjas.dk
    >> >
    >> >
    >> >
    >> > "lucky" wrote:
    >> >
    >> >> hi guys,
    >> >> right now i'm going through System.Globalization Namespace. and i
    >> >> found very intersting class there called CultureInfo.
    >> >>
    >> >> i was trying to get cultureInfo on the basis of name but i didnt find
    >> >> the way to do it. for example, if i pass the language name
    >> >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    >> >> of the language.
    >> >>
    >> >> can anyone help me out here?
    >> >> i would appriciate any help.
    >> >>
    >> >> thanks,
    >> >> Lucky
    >> >>
    >> >>

    >>
    >>
    >>
    Juan T. Llibre, Jan 31, 2007
    #8
  9. Excellent. You might want to post the code here for the OP to see?

    :) Jakob.


    "Juan T. Llibre" wrote:

    > re:
    > > create a new CultureInfo from EnglishName which can not be done easily

    >
    > Aw, that's not so hard to do :
    >
    > http://asp.net.do/test/culture3.aspx
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "Jakob Christensen" <> wrote in message
    > news:...
    > > The OP wants to create a new CultureInfo from EnglishName which can not be
    > > done easily. I do not think that CurrentCulture is of much use here.
    > >
    > > :) Jakob.
    > >
    > >
    > >
    > > "Juan T. Llibre" wrote:
    > >
    > >> Or, you could simply use these :
    > >>
    > >> CultureInfo.CurrentCulture.EnglishName
    > >> CultureInfo.CurrentCulture.DisplayName
    > >> CultureInfo.CurrentCulture.NativeName
    > >>
    > >>
    > >>
    > >>
    > >> Juan T. Llibre, asp.net MVP
    > >> asp.net faq : http://asp.net.do/faq/
    > >> foros de asp.net, en español : http://asp.net.do/foros/
    > >> ===================================
    > >> "Jakob Christensen" <> wrote in message
    > >> news:...
    > >> > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    > >> > following link shows the complete list:
    > >> > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    > >> >
    > >> > Regards, Jakob.
    > >> > --
    > >> > http://www.dotninjas.dk
    > >> >
    > >> >
    > >> >
    > >> > "lucky" wrote:
    > >> >
    > >> >> hi guys,
    > >> >> right now i'm going through System.Globalization Namespace. and i
    > >> >> found very intersting class there called CultureInfo.
    > >> >>
    > >> >> i was trying to get cultureInfo on the basis of name but i didnt find
    > >> >> the way to do it. for example, if i pass the language name
    > >> >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > >> >> of the language.
    > >> >>
    > >> >> can anyone help me out here?
    > >> >> i would appriciate any help.
    > >> >>
    > >> >> thanks,
    > >> >> Lucky
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=, Jan 31, 2007
    #9
  10. re:
    > You might want to post the code here for the OP to see?


    Why not?

    If I had a nickel for every line of code I've given away for free here
    ....well, you know how the rest of that goes. :)

    Here's the crux...and the trick.

    <%@ Page Language="VB" uiculture="auto" %>
    <%@ Import Namespace="System.Threading" %>
    <%@ Import Namespace="System.Globalization" %>

    <script runat="server">
    Protected Overrides Sub InitializeCulture()
    If Request.Form("ListBox1") IsNot Nothing Then
    Dim selectedLanguage As String = Request.Form("ListBox1")
    UICulture = Request.Form("ListBox1")
    Culture = Request.Form("ListBox1")
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage)
    Thread.CurrentThread.CurrentUICulture = New CultureInfo(selectedLanguage)
    End If
    MyBase.InitializeCulture()
    End Sub
    </script>

    <form id="form1" runat="server">
    <div>
    <asp:ListBox ID="ListBox1" runat="server">
    <asp:ListItem Value="en-US" Selected="True">English</asp:ListItem>
    <asp:ListItem Value="es-MX">Español</asp:ListItem>
    <asp:ListItem Value="de-DE">Deutsch</asp:ListItem>
    </asp:ListBox><br />
    <asp:Button ID="Button1" runat="server"
    Text="Set Language"
    meta:resourcekey="Button1" />
    <br />
    </div>

    The trick, as should be obvious by now, is that you don't *need* to pass the EnglishName.

    The value that we *do* pass is CultureInfo.CurrentCulture.Name,
    but we *display* whatever name we want to display to the user.

    That way, it's transparent to the user *and* easy to program as well.

    One of the most difficult concepts to grasp in programming
    is that we should not attempt to lock a route to the desired result.

    As long as we get where we want to get to, any route is OK.

    Some routes are impossible and some are a waste,
    but getting to where we want to get, with the least effort expended, is what counts.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Jakob Christensen" <> wrote in message
    news:...
    > Excellent. You might want to post the code here for the OP to see?
    >
    > :) Jakob.
    >
    >
    > "Juan T. Llibre" wrote:
    >
    >> re:
    >> > create a new CultureInfo from EnglishName which can not be done easily

    >>
    >> Aw, that's not so hard to do :
    >>
    >> http://asp.net.do/test/culture3.aspx
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> asp.net faq : http://asp.net.do/faq/
    >> foros de asp.net, en español : http://asp.net.do/foros/
    >> ===================================
    >> "Jakob Christensen" <> wrote in message
    >> news:...
    >> > The OP wants to create a new CultureInfo from EnglishName which can not be
    >> > done easily. I do not think that CurrentCulture is of much use here.
    >> >
    >> > :) Jakob.
    >> >
    >> >
    >> >
    >> > "Juan T. Llibre" wrote:
    >> >
    >> >> Or, you could simply use these :
    >> >>
    >> >> CultureInfo.CurrentCulture.EnglishName
    >> >> CultureInfo.CurrentCulture.DisplayName
    >> >> CultureInfo.CurrentCulture.NativeName
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> Juan T. Llibre, asp.net MVP
    >> >> asp.net faq : http://asp.net.do/faq/
    >> >> foros de asp.net, en español : http://asp.net.do/foros/
    >> >> ===================================
    >> >> "Jakob Christensen" <> wrote in message
    >> >> news:...
    >> >> > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    >> >> > following link shows the complete list:
    >> >> > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    >> >> >
    >> >> > Regards, Jakob.
    >> >> > --
    >> >> > http://www.dotninjas.dk
    >> >> >
    >> >> >
    >> >> >
    >> >> > "lucky" wrote:
    >> >> >
    >> >> >> hi guys,
    >> >> >> right now i'm going through System.Globalization Namespace. and i
    >> >> >> found very intersting class there called CultureInfo.
    >> >> >>
    >> >> >> i was trying to get cultureInfo on the basis of name but i didnt find
    >> >> >> the way to do it. for example, if i pass the language name
    >> >> >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    >> >> >> of the language.
    >> >> >>
    >> >> >> can anyone help me out here?
    >> >> >> i would appriciate any help.
    >> >> >>
    >> >> >> thanks,
    >> >> >> Lucky
    >> >> >>
    >> >> >>
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    Juan T. Llibre, Jan 31, 2007
    #10
  11. Aaah, but you still have not solved Lucky's problem (the OP). You are just
    using the culture name (i.e. "en-US" etc.) as I suggested in my first reply
    to the OP. Lucky wants to create the CultureInfo directly from the string
    "Danish" or "Russian". Nobody says that he can do what you did.

    :) Jakob.



    "Juan T. Llibre" wrote:

    > re:
    > > You might want to post the code here for the OP to see?

    >
    > Why not?
    >
    > If I had a nickel for every line of code I've given away for free here
    > ....well, you know how the rest of that goes. :)
    >
    > Here's the crux...and the trick.
    >
    > <%@ Page Language="VB" uiculture="auto" %>
    > <%@ Import Namespace="System.Threading" %>
    > <%@ Import Namespace="System.Globalization" %>
    >
    > <script runat="server">
    > Protected Overrides Sub InitializeCulture()
    > If Request.Form("ListBox1") IsNot Nothing Then
    > Dim selectedLanguage As String = Request.Form("ListBox1")
    > UICulture = Request.Form("ListBox1")
    > Culture = Request.Form("ListBox1")
    > Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage)
    > Thread.CurrentThread.CurrentUICulture = New CultureInfo(selectedLanguage)
    > End If
    > MyBase.InitializeCulture()
    > End Sub
    > </script>
    >
    > <form id="form1" runat="server">
    > <div>
    > <asp:ListBox ID="ListBox1" runat="server">
    > <asp:ListItem Value="en-US" Selected="True">English</asp:ListItem>
    > <asp:ListItem Value="es-MX">Español</asp:ListItem>
    > <asp:ListItem Value="de-DE">Deutsch</asp:ListItem>
    > </asp:ListBox><br />
    > <asp:Button ID="Button1" runat="server"
    > Text="Set Language"
    > meta:resourcekey="Button1" />
    > <br />
    > </div>
    >
    > The trick, as should be obvious by now, is that you don't *need* to pass the EnglishName.
    >
    > The value that we *do* pass is CultureInfo.CurrentCulture.Name,
    > but we *display* whatever name we want to display to the user.
    >
    > That way, it's transparent to the user *and* easy to program as well.
    >
    > One of the most difficult concepts to grasp in programming
    > is that we should not attempt to lock a route to the desired result.
    >
    > As long as we get where we want to get to, any route is OK.
    >
    > Some routes are impossible and some are a waste,
    > but getting to where we want to get, with the least effort expended, is what counts.
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ===================================
    > "Jakob Christensen" <> wrote in message
    > news:...
    > > Excellent. You might want to post the code here for the OP to see?
    > >
    > > :) Jakob.
    > >
    > >
    > > "Juan T. Llibre" wrote:
    > >
    > >> re:
    > >> > create a new CultureInfo from EnglishName which can not be done easily
    > >>
    > >> Aw, that's not so hard to do :
    > >>
    > >> http://asp.net.do/test/culture3.aspx
    > >>
    > >>
    > >>
    > >> Juan T. Llibre, asp.net MVP
    > >> asp.net faq : http://asp.net.do/faq/
    > >> foros de asp.net, en español : http://asp.net.do/foros/
    > >> ===================================
    > >> "Jakob Christensen" <> wrote in message
    > >> news:...
    > >> > The OP wants to create a new CultureInfo from EnglishName which can not be
    > >> > done easily. I do not think that CurrentCulture is of much use here.
    > >> >
    > >> > :) Jakob.
    > >> >
    > >> >
    > >> >
    > >> > "Juan T. Llibre" wrote:
    > >> >
    > >> >> Or, you could simply use these :
    > >> >>
    > >> >> CultureInfo.CurrentCulture.EnglishName
    > >> >> CultureInfo.CurrentCulture.DisplayName
    > >> >> CultureInfo.CurrentCulture.NativeName
    > >> >>
    > >> >>
    > >> >>
    > >> >>
    > >> >> Juan T. Llibre, asp.net MVP
    > >> >> asp.net faq : http://asp.net.do/faq/
    > >> >> foros de asp.net, en español : http://asp.net.do/foros/
    > >> >> ===================================
    > >> >> "Jakob Christensen" <> wrote in message
    > >> >> news:...
    > >> >> > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    > >> >> > following link shows the complete list:
    > >> >> > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    > >> >> >
    > >> >> > Regards, Jakob.
    > >> >> > --
    > >> >> > http://www.dotninjas.dk
    > >> >> >
    > >> >> >
    > >> >> >
    > >> >> > "lucky" wrote:
    > >> >> >
    > >> >> >> hi guys,
    > >> >> >> right now i'm going through System.Globalization Namespace. and i
    > >> >> >> found very intersting class there called CultureInfo.
    > >> >> >>
    > >> >> >> i was trying to get cultureInfo on the basis of name but i didnt find
    > >> >> >> the way to do it. for example, if i pass the language name
    > >> >> >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    > >> >> >> of the language.
    > >> >> >>
    > >> >> >> can anyone help me out here?
    > >> >> >> i would appriciate any help.
    > >> >> >>
    > >> >> >> thanks,
    > >> >> >> Lucky
    > >> >> >>
    > >> >> >>
    > >> >>
    > >> >>
    > >> >>
    > >>
    > >>
    > >>

    >
    >
    >
    >
    =?Utf-8?B?SmFrb2IgQ2hyaXN0ZW5zZW4=?=, Jan 31, 2007
    #11
  12. Still, working around a programming task is better than not doing anything, right ?

    What I'm saying ( and it's a bit hard to understand, I know )
    is that we should not get hung up on a particular way of doing a task.

    As long as we deliver a solution, it's OK.

    The OP certainly won't be needing to deliver a solution
    for *all* the possible languages/cultures, right ?

    So, the proposed solution I coded *will* work for a fairly large
    subset of the available languages/cultures ( the ones which
    will fit into the Listbox without making it an unwieldy instrument ).




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Jakob Christensen" <> wrote in message
    news:...
    > Aaah, but you still have not solved Lucky's problem (the OP). You are just
    > using the culture name (i.e. "en-US" etc.) as I suggested in my first reply
    > to the OP. Lucky wants to create the CultureInfo directly from the string
    > "Danish" or "Russian". Nobody says that he can do what you did.
    >
    > :) Jakob.
    >
    >
    >
    > "Juan T. Llibre" wrote:
    >
    >> re:
    >> > You might want to post the code here for the OP to see?

    >>
    >> Why not?
    >>
    >> If I had a nickel for every line of code I've given away for free here
    >> ....well, you know how the rest of that goes. :)
    >>
    >> Here's the crux...and the trick.
    >>
    >> <%@ Page Language="VB" uiculture="auto" %>
    >> <%@ Import Namespace="System.Threading" %>
    >> <%@ Import Namespace="System.Globalization" %>
    >>
    >> <script runat="server">
    >> Protected Overrides Sub InitializeCulture()
    >> If Request.Form("ListBox1") IsNot Nothing Then
    >> Dim selectedLanguage As String = Request.Form("ListBox1")
    >> UICulture = Request.Form("ListBox1")
    >> Culture = Request.Form("ListBox1")
    >> Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage)
    >> Thread.CurrentThread.CurrentUICulture = New CultureInfo(selectedLanguage)
    >> End If
    >> MyBase.InitializeCulture()
    >> End Sub
    >> </script>
    >>
    >> <form id="form1" runat="server">
    >> <div>
    >> <asp:ListBox ID="ListBox1" runat="server">
    >> <asp:ListItem Value="en-US" Selected="True">English</asp:ListItem>
    >> <asp:ListItem Value="es-MX">Español</asp:ListItem>
    >> <asp:ListItem Value="de-DE">Deutsch</asp:ListItem>
    >> </asp:ListBox><br />
    >> <asp:Button ID="Button1" runat="server"
    >> Text="Set Language"
    >> meta:resourcekey="Button1" />
    >> <br />
    >> </div>
    >>
    >> The trick, as should be obvious by now, is that you don't *need* to pass the EnglishName.
    >>
    >> The value that we *do* pass is CultureInfo.CurrentCulture.Name,
    >> but we *display* whatever name we want to display to the user.
    >>
    >> That way, it's transparent to the user *and* easy to program as well.
    >>
    >> One of the most difficult concepts to grasp in programming
    >> is that we should not attempt to lock a route to the desired result.
    >>
    >> As long as we get where we want to get to, any route is OK.
    >>
    >> Some routes are impossible and some are a waste,
    >> but getting to where we want to get, with the least effort expended, is what counts.
    >>
    >>
    >>
    >>
    >> Juan T. Llibre, asp.net MVP
    >> asp.net faq : http://asp.net.do/faq/
    >> foros de asp.net, en español : http://asp.net.do/foros/
    >> ===================================
    >> "Jakob Christensen" <> wrote in message
    >> news:...
    >> > Excellent. You might want to post the code here for the OP to see?
    >> >
    >> > :) Jakob.
    >> >
    >> >
    >> > "Juan T. Llibre" wrote:
    >> >
    >> >> re:
    >> >> > create a new CultureInfo from EnglishName which can not be done easily
    >> >>
    >> >> Aw, that's not so hard to do :
    >> >>
    >> >> http://asp.net.do/test/culture3.aspx
    >> >>
    >> >>
    >> >>
    >> >> Juan T. Llibre, asp.net MVP
    >> >> asp.net faq : http://asp.net.do/faq/
    >> >> foros de asp.net, en español : http://asp.net.do/foros/
    >> >> ===================================
    >> >> "Jakob Christensen" <> wrote in message
    >> >> news:...
    >> >> > The OP wants to create a new CultureInfo from EnglishName which can not be
    >> >> > done easily. I do not think that CurrentCulture is of much use here.
    >> >> >
    >> >> > :) Jakob.
    >> >> >
    >> >> >
    >> >> >
    >> >> > "Juan T. Llibre" wrote:
    >> >> >
    >> >> >> Or, you could simply use these :
    >> >> >>
    >> >> >> CultureInfo.CurrentCulture.EnglishName
    >> >> >> CultureInfo.CurrentCulture.DisplayName
    >> >> >> CultureInfo.CurrentCulture.NativeName
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >>
    >> >> >> Juan T. Llibre, asp.net MVP
    >> >> >> asp.net faq : http://asp.net.do/faq/
    >> >> >> foros de asp.net, en español : http://asp.net.do/foros/
    >> >> >> ===================================
    >> >> >> "Jakob Christensen" <> wrote in message
    >> >> >> news:...
    >> >> >> > You need to pass the culture name, i.e. "da-DK", "de-DE" or "ru-RU". The
    >> >> >> > following link shows the complete list:
    >> >> >> > http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx
    >> >> >> >
    >> >> >> > Regards, Jakob.
    >> >> >> > --
    >> >> >> > http://www.dotninjas.dk
    >> >> >> >
    >> >> >> >
    >> >> >> >
    >> >> >> > "lucky" wrote:
    >> >> >> >
    >> >> >> >> hi guys,
    >> >> >> >> right now i'm going through System.Globalization Namespace. and i
    >> >> >> >> found very intersting class there called CultureInfo.
    >> >> >> >>
    >> >> >> >> i was trying to get cultureInfo on the basis of name but i didnt find
    >> >> >> >> the way to do it. for example, if i pass the language name
    >> >> >> >> "Danish","German",Russian", i'm suppose to get the cultureInfo object
    >> >> >> >> of the language.
    >> >> >> >>
    >> >> >> >> can anyone help me out here?
    >> >> >> >> i would appriciate any help.
    >> >> >> >>
    >> >> >> >> thanks,
    >> >> >> >> Lucky
    >> >> >> >>
    >> >> >> >>
    >> >> >>
    >> >> >>
    >> >> >>
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
    >>
    Juan T. Llibre, Jan 31, 2007
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dejan Vesic
    Replies:
    1
    Views:
    666
    Chee Seong Ong
    Jul 3, 2003
  2. Vidar Petursson

    Re: Javascript: date in culture/language format.

    Vidar Petursson, Aug 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    5,497
    Vidar Petursson
    Aug 15, 2003
  3. Mircea Pleteriu

    Crystal Reports Culture Info

    Mircea Pleteriu, Aug 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    839
    Mircea Pleteriu
    Aug 28, 2003
  4. Joe Van Meer

    Culture Info & Datetime values

    Joe Van Meer, Nov 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    438
    Joe Van Meer
    Nov 22, 2005
  5. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    get client user culture info

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Jun 22, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    580
    Walter Wang [MSFT]
    Jun 22, 2006
Loading...

Share This Page