Localization Thread culture issue

Rate It (2)

Last post 04-26-2007 11:38 AM by kipo. 9 replies.

Sort Posts:

  • Localization Thread culture issue

    04-26-2007, 2:46 AM

    Hi ,

     I am working  on localizatin in asp.net 2.0, We r working on multi language web site , so user can toggle between english and french thread and ui cultures.

    Now the issue is , user can always enter data in english mode only ( means 10.25, 30.55, 66.22) , After all the calculations happend i want to display all the page ui controls in French mode with commas ( 10,25, 30,55). Is there any way to resolve this issue . If i am in french mode if user enterd dot(.) 10.25 like that , page throwing error.

     

    any suggestions plzzzzzzzzz

    Suresh kumar Telu
    sryas software Pvt Ltd
  • Re: Localization Thread culture issue

    04-26-2007, 4:08 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 9:22 AM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    Are you using the French keyboard layout to enter the data when you are in French mode? Also is the exception its throwing?

    Thanks

    Mark post(s) as "Answer" that helped you

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: Localization Thread culture issue

    04-26-2007, 4:16 AM
    • Loading...
    • kipo
    • Joined on 07-20-2006, 3:10 AM
    • Croatia
    • Posts 1,600

    You can replace comma with dot (or backwards) right after user enter number with this approach:

    TextBox1.Text.Replace(',', '.')

  • Re: Localization Thread culture issue

    04-26-2007, 4:37 AM
    Thanks
    Suresh kumar Telu
    sryas software Pvt Ltd
  • Re: Localization Thread culture issue

    04-26-2007, 4:37 AM

    but i am trying to do some thing generic

    Suresh kumar Telu
    sryas software Pvt Ltd
  • Re: Localization Thread culture issue

    04-26-2007, 4:45 AM

    hi kipo,

      that works fine for textbox control , what is abt all the remaining controls .

      I am talking not only abt dot or comma , the user will must and should enter the data in "en-US" mode only , all the calculations will happen in english and finally at the time of rendering i want to display the page in french. Is there any way to do like this.

    Suresh kumar Telu
    sryas software Pvt Ltd
  • Re: Localization Thread culture issue

    04-26-2007, 5:30 AM
    • Loading...
    • kipo
    • Joined on 07-20-2006, 3:10 AM
    • Croatia
    • Posts 1,600

    You can do the same logic for all the other contorols, too. For example if you are doing output in Label you can do this:

    double dec = 10.04;
    Label1.Text = dec.ToString().Replace('.',',');

  • Re: Localization Thread culture issue

    04-26-2007, 5:39 AM
    • Loading...
    • kipo
    • Joined on 07-20-2006, 3:10 AM
    • Croatia
    • Posts 1,600

    You can try with this approach too:

    using System.Globalization;

    CultureInfo info = new CultureInfo("fr-FR");
    double dec = 10.04;
    Label1.Text = dec.ToString("c", info);

  • Re: Localization Thread culture issue

    04-26-2007, 10:06 AM

    My project contains more than 100 pages in that , Today Problem with only one Culture french ,

    Tomorrow i want to toggle 3 or 4 langues , this code will breaks,

    is there any way is there to set in global.asax  file

    Suresh kumar Telu
    sryas software Pvt Ltd
  • Re: Localization Thread culture issue

    04-26-2007, 11:38 AM
    Answer
    • Loading...
    • kipo
    • Joined on 07-20-2006, 3:10 AM
    • Croatia
    • Posts 1,600

    Maybe this will help you (Label is there just for demonstration purposes, only important part is InitializeCulture):

    Default.aspx:
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                <asp:ListItem Value="en-US"></asp:ListItem>
                <asp:ListItem Value="fr-FR"></asp:ListItem>
    </asp:DropDownList>
    <br />
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    Default.aspx.cs:
    protected void Page_Load(object sender, EventArgs e)
        {
            double cur = 10.00;
            Label1.Text = cur.ToString("c");
        }
    protected override void InitializeCulture()
        {
            if (Request.Form["DropDownList1"] != null)
            {
                Culture = Request.Form["DropDownList1"];
            }
            base.InitializeCulture();
        }

Page 1 of 1 (10 items)
Microsoft Communities
Page view counter