locked
Problem with Globalization and Multilanguage web-page RRS feed

  • Question

  • User540168148 posted
    Hi, I have this code in my master page (plantilla0.master):
    <li>[<asp:HyperLink ID="link_es" runat="server" ToolTip="idioma español" NavigateUrl="index.aspx?lng=es-ES" meta:resourcekey="link_esResource1" Text="es"></asp:HyperLink>]</li>
    <li>[<asp:HyperLink ID="link_en" runat="server" ToolTip="idioma inglés" NavigateUrl="index.aspx?lng=en-US" meta:resourcekey="link_enResource1" Text="en"></asp:HyperLink>]</li>
    <li>[<asp:HyperLink ID="link_pt" runat="server" ToolTip="idioma portugués" NavigateUrl="index.aspx?lng=pt-PT" meta:resourcekey="link_ptResource1" Text="pt"></asp:HyperLink>]</li>
    As you can see there is a resource file associated to manage the language:

    default resource file that is in Spanish
    plantilla0.master.resx

    and another one  in Eglish
    plantilla0.master.en.resx

    In web.config  I've set <globalization culture="auto" uiCulture="auto"/>

    And in pl
    lantilla0.master.cs:

    public
    partial class MasterPage : System.Web.UI.MasterPage
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (this.Session["idioma"] == null)
    {
    if (Request.UserLanguages[0] != null)
    {
    this.Session["idioma"] = Request.UserLanguages[0];
    }
    else
    {
    this.Session["idioma"] = "es";
    }
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(this.Session["idioma"].ToString());
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.Session["idioma"].ToString());
    }
    else
    {
    string lng;
    lng = Request.QueryString["lng"];
    if (lng != null)
    {
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lng);
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(lng);
    this.Session["idioma"] = lng;
    }
    }
    }
    }


    The thing is that this doesn't work... I click to change the language but nothing happens...
    If I execute in debug mode, I verify values in

    Thread.CurrentThread.CurrentCulture
    Thread.CurrentThread.CurrentUICulture

    they are correct, but at least never change the language of the web
    any idea or sugestion???

    thanks a lot!
    Thursday, July 27, 2006 7:12 AM

All replies

  • User-1936818034 posted

    Your code doesn't work because culture info is actually set in a method InitializeCulture() of the page class, but when it comes to masterpage, notice it's a control but not a page, and it's lifecycle is not that integrated as a page: one evidence is that it has no InitialCulture() ~

    SO plz try the solution discussed in This Post~

    Friday, July 28, 2006 12:15 AM