Not able to change Language

Last post 09-24-2007 7:38 PM by barrysuku. 6 replies.

Sort Posts:

  • Not able to change Language

    09-23-2007, 9:24 PM
    • Loading...
    • barrysuku
    • Joined on 05-22-2007, 8:02 PM
    • Posts 71

    Am facing problem in doing Localization.

    I am having two Link Buttons named as English and Chinese. Am having resource file for chinese zh-CN.
    Am doing this on click event of chinese LinkButton.

    Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");

    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("zh-CN");

    But my page langugae is not changing from English to Chinese. Help me.

  • Re: Not able to change Language

    09-24-2007, 2:48 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    You need to override the InitializeCulture event of the Page, to set the new cultureInfo

     

    //using System.Reflection;
    using System.Threading;
    public partial class TestPage : System.Web.UI.Page
    {
        protected override void InitializeCulture()
        {
            string _userLanguage = string.Empty;
            if (Session["userLanguage"] != null)
                _userLanguage = Session["userLanguage"].ToString();
            if (_userLanguage != "")
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(_userLanguage);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(_userLanguage);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            // store the user preferred language in a session
            Session["userLanguage"] = "zh-CN";
        }
    }

    Thanks

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

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

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: Not able to change Language

    09-24-2007, 3:02 AM
    • Loading...
    • barrysuku
    • Joined on 05-22-2007, 8:02 PM
    • Posts 71

    I was able to do that. Now am facing two problems

    1. Hyperlinks in My Gridview changes to chinese and when i try to change it back to English not converting from Chinese to  english. All other contents changed to English Except HyperLinks in GridView.

    2.Am using AJAX CalenderExtender and calender is still showing english when i change the langugae to Chinese.

  • Re: Not able to change Language

    09-24-2007, 3:15 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    Is it just the HyperLinks in the grid that dont change back to english or all the other content in the grid?

    For the Ajax CalendarExtender, check Kriz blog entry at http://blog.krisvandermast.com/EnableGlobalizationPropertyOnTheScriptManager.aspx

    Thanks

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

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

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: Not able to change Language

    09-24-2007, 3:56 AM
    • Loading...
    • barrysuku
    • Joined on 05-22-2007, 8:02 PM
    • Posts 71

    Yeh only HyperLinks in GridView which are not changing to English.

    Once converted from English to Chinese.

  • Re: Not able to change Language

    09-24-2007, 4:06 AM
    • Loading...
    • e_screw
    • Joined on 10-20-2004, 1:22 PM
    • Women, Guitar, Russia, Billiards, Nature, .NET
    • Posts 3,854

    Make sure you have the equivalent english entries for the hyperlinks in the english resource file.

    Thanks

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

    Electronic Screw
    Website||Blog||Dub@i.net
  • Re: Not able to change Language

    09-24-2007, 7:38 PM
    • Loading...
    • barrysuku
    • Joined on 05-22-2007, 8:02 PM
    • Posts 71

    Everything is Ok. Resource Files are ok.
    Resource files are like default.aspx.resx & default.aspx.zh-CN.resx and are in App_LocalResources folder.

    I need to do anything in WebConfig for that?

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