Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2007, 02:49 PM
Registered User
 
Join Date: Jul 2006
Location: , , .
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
                    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.





Reply With Quote
  #2 (permalink)  
Old June 9th, 2007, 09:44 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:39 AM.


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