Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 8th, 2007, 02:49 PM
Registered User
Join Date: Jul 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Localization Issues

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
                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>

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.

Old June 9th, 2007, 09:44 AM
Registered User
Join Date: Jul 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

Ahh, no worries, I sorted this one myself. I needed to use the GetGlobalResource Method (e.g. label1.Text = Convert.ToString("globalResources", "labelTextResource"). That did the trick!

Similar Threads
Thread Thread Starter Forum Replies Last Post
localization veda ASP.NET 2.0 Basics 2 August 4th, 2008 07:48 AM
connection string issues, web.config file issues kaliaparijat ASP.NET 2.0 Professional 1 June 12th, 2008 08:07 AM
Globalization and Localization madhuriguda .NET Framework 2.0 1 April 28th, 2008 05:20 AM
localization mohitkumarpaliwal ASP.NET 1.x and 2.0 Application Design 1 July 26th, 2007 03:09 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.