Localization Issue

Last post 02-21-2008 9:33 AM by deekonda. 3 replies.

Sort Posts:

  • Localization Issue

    02-20-2008, 3:50 PM
    • Loading...
    • deekonda
    • Joined on 02-20-2008, 3:38 PM
    • Posts 5

    Hi All,

    I am converting a static page en-fr. In vs2k5 I use the GenerateLocalResource tool to generate .resx files and copied and renamed in fr.

    In my Masteer page, I have a link en/fr, where user get there choice of selection. I create a basepage , global.asax where I am using cookies.

    My question is: when a user click on the link en / fr. where I can set the cookie value, is it in Masterpage / global / basepage?

    what the changes I need to make in web.config, I am using (

    <globalization enableClientBasedCulture="true" culture="fr-FR" uiCulture="fr-FR"/>)

    and I have bunches of french written documents to keep in .fr.resx files, Is there any smart way to convert fr word doc to html format

    and keep it fr.resx files.

    Many thanks

     

     

     

     

  • Re: Localization Issue

    02-20-2008, 11:46 PM
    • Loading...
    • sachingusain
    • Joined on 02-18-2008, 6:58 AM
    • India
    • Posts 62

    You have to set the cookie in the basepage's (.ASPX) code behind file.

    To set culture dynamically, you can use following code in global.asax

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
         CultureInfo c = new CultureInfo("en-GB");
         Thread.CurrentThread.CurrentUICulture = c;
         Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
    }

    Or, following snippet in your ASPX code-behind:

    protected void Page_Load(object sender, EventArgs e)
    {
         CultureInfo c = new CultureInfo("en-GB");
         Thread.CurrentThread.CurrentUICulture = c;
         Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
    }

  • Re: Localization Issue

    02-21-2008, 2:19 AM
    • Loading...
    • vivek_iit
    • Joined on 06-18-2006, 6:13 PM
    • New Delhi
    • Posts 3,072
    • TrustedFriends-MVPs

    deekonda:
    My question is: when a user click on the link en / fr. where I can set the cookie value, is it in Masterpage / global / basepage?
     

    I suggest you put it in BasePage class as shown in this article:

    http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.asp

    deekonda:

    and I have bunches of french written documents to keep in .fr.resx files, Is there any smart way to convert fr word doc to html format

    and keep it fr.resx files.

     

    You will need to manually insert the values in the RESX files, or you can build a tool around it that will capture values from the source files and insert it into RESX file.

    Hope this helps,

    Vivek 

    MVP, ASP.NET || My Website || Blog || Articles

    Please mark the most helpful reply/replies as "Answer".
  • Re: Master page Issue

    02-21-2008, 9:33 AM
    • Loading...
    • deekonda
    • Joined on 02-20-2008, 3:38 PM
    • Posts 5

     In the master page I have the link enlish/french link buttons.
    for instance Code for frech in master page is
     public void lnkFrench_Click(Object sender, EventArgs e)
        {
            strLanguge = "fr-CA";
            if (string.IsNullOrEmpty(strLanguge)) { strLanguge = "fr-CA"; }
            HttpCookie myCookie = new HttpCookie("languageOfChoice");
            myCookie.Value = strLanguge;
            Response.SetCookie(myCookie);
            
        }
    and in my baseclass
     protected override void InitializeCulture()
            {
                //Default to Invariant Culture
                string strCulture = string.Empty;
                HttpCookie myAppCookie = Request.Cookies["languageOfChoice"];

                if (myAppCookie != null && myAppCookie.Value != null)
                {
                    strCulture = myAppCookie.Value;
                    Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(strCulture);
                    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(strCulture);
                }

                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(strCulture);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(strCulture);

                base.InitializeCulture();

            }

    and in Gloabal.asax
     void Application_BeginRequest(object sender, EventArgs e)
        {
            string strLang = string.Empty;
            HttpCookie myCookie = Request.Cookies["languageOfChoice"];

            if (myCookie != null && myCookie.Value != null)
                strLang = myCookie.Value;
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(strLang);
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(strLang);
        }

    --------------------------------------------------------------
    when I click 2 times on the link button it refreshing in french.
    Any solutions please

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