Sometimes, we’d stored a cookie with the user language preference. But, the fact of change the Page.UICulture don’t have any resoult.
To changed this property we should do it inside the InitializeCulture Page method and override it. Imagine that the cookie is called “lang”:
protected override void InitializeCulture()
{
if (Request.Cookies["lang"] != null)
{
if (Request.Cookies["lang"].Value != "")
{
Page.UICulture = Request.Cookies["lang"].Value;
}
}
base.InitializeCulture();
}
Thus, you could change the page language ;).
También pudo ser con String.IsNullOrEmpty ¿?. Habrá diferencias en rendimiento? jejeje si lo hubieran serían ínfimos o casi nulos seguros jejeje.
protected override void InitializeCulture()
{
if(!String.IsNullOrEmpty(Request.Cookies[«lang»].Value))
Page.UICulture = Request.Cookies[«lang»].Value;
base.InitializeCulture();
}
Buen post!
Saludos
Gracias por tu respuesta!
No había pensado en eso, pero me imagino que si que habrá mejoras de rendimiento pero habría que mirar el código interno para comprobarlo.
Cuando pueda le echo un ojo y comento 🙂
Un saludo!
Hola Euge:
Te dejo algunas aportaciones más a este post en uno mío que publiqué hace ya algún tiempo:
http://www.jasoft.org/blog/PermaLink,guid,659bc8a5-5f82-43c9-9379-8127b4e90bd7.aspx
Saludos
JM
Porque no en el evento load (está en VB):
Imports System.Globalization
Imports System.Threading
…..
….
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(«es-PE»)