Hi all,
My ASP.Net 2 app has a localization problem. What I'm trying to do (and I guess plenty of people have done the same) is two things; allow the user to select their UI language from a drop down list (for non-authenticated users) and to store and use their required language in their profile (for authenticated users). My
VB code (in script tags is as follows):
Protected Overrides Sub InitializeCulture()
Dim lang As String = Request.Form("ddlLanguage")
If (lang <> Nothing) Then
If lang <> "" Then
Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang)
Page.UICulture = lang
Page.Culture = lang
Me.InitializeCulture()
End If
End If
End Sub
I've imported the correct namespaces, so I know that's not an issue. The associated drop-down field code is as follows:
<asp:DropDownList ID="ddlLanguage" runat="server" AutoPostBack="True">
<asp:ListItem Selected="True" Value="auto">Auto</asp:ListItem>
<asp:ListItem Value="en-US">English (US)</asp:ListItem>
<asp:ListItem Value="en-GB">English (UK)</asp:ListItem>
<asp:ListItem Value="ar">Arabic</asp:ListItem>
<asp:ListItem Value="fr">French</asp:ListItem>
<asp:ListItem Value="zh-CN">Chinese</asp:ListItem>
</asp:DropDownList>
I don't know why, but the code is not initialising the selected language (all the text I want to translate is stored in a globalresources.resx file for each language, and I have explicitly set each resource on each label, etc)
Can anyone tell me what I'm doing wrong? Any help would be appreciated. I think If someone could tell me what's going wrong here, I could probably work out the profile (for authenticated users) problem myself.
Thanks, in advance,
Graham C.