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 pllantilla0.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!