Imar,
If we were to Globalize your example in PlanetWrox and place a language selection (Itemlist control and button) in the Sidebar (located in the Masterpage), how could we get the Override ( protected override void InitializeCulture()) to work. From what I have seen, it cannot reside in the masterpage. The control for the language selection would naturally look better if it was in the sidebar.
As a concept, how could I resolve the issue?
I ran a simple example of a globalized ASP page with its resource files and it wasn't difficult.
Code:
<%@ Page Language="C#" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
<script runat="server">
protected override void InitializeCulture()
{
if (Request.Form["ListBox1"] != null)
{
String selectedLanguage = Request.Form["ListBox1"];
UICulture = selectedLanguage ;
Culture = selectedLanguage ;
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage);
}
base.InitializeCulture();
}
</script>
<html>
<head><title>Set Culture</title></head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox id="ListBox1" runat="server">
<asp:ListItem value="en-US"
selected="True">English</asp:ListItem>
<asp:ListItem value="es-MX">Español</asp:ListItem>
<asp:ListItem value="de-DE">Deutsch</asp:ListItem>
</asp:ListBox><br />
<asp:Button id="Button1" runat="server" Text="<%$ Resources:Resource, Button1 %>"/>
<br />
<asp:Label id="Label1" runat="server" Text="<%$ Resources:Resource, Label1 %>" />
</div>
<asp:Button ID="Button2" runat="server" Text="<%$ Resources:Resource, Button2 %>" />
</form>
</body>
</html>