Localization

B

Bruno Alexandre

Hi Guys,

I'm driving crazy here with Localization issue, this is what I have now:

masterpage.master - with some asp:linkbutton like this:

<asp:LinkButton PostBackUrl="~/login/Default.aspx" ID="lnkLogout"
runat="server" Text="<%$ Resources:language, menu_logout %>" />


Default.aspx - with some labels and Dropdowns for Login propose and in
the top of the page:
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="login_Default" Culture="auto:en-US"
UICulture="auto" %>

in Default.aspx.vb one of other thinks is:

Protected Overrides Sub InitializeCulture()
Dim lang As String = Request("ddLanguage")
If lang IsNot Nothing Or lang <> "" Then
Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang)
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(lang)
End If
End Sub


and it works FINE!
but the language choose in this DEFAULT.ASPX file is not the same in the
other pages of the website, it only overrides the CultureInfo in this
DEFAULT.ASPX file...


How can I choose a language in the Default.aspx and have THAT language
across HOLE Webpage?

I'm USING GlobalResources and a Resource called Language.resx with
several for other languages like:

Language.pt.resx
Language.fr.resx
Language.da.resx

etc...


Anyone Know how can I manage this?

I already watch this HOW TO...
ASP.NET HOW DO I Video Series: Localization
http://msdn.microsoft.com/asp.net/learning/learn/newtodevelopment/default.aspx


but this example is just for one page (even using globalResources)


Thanks in Advance.

Bruno Alexandre
"a Portuguese in København, Danmark"
 
J

Jules

As far as I can see, you have two options;

1) Move the code you have in the InitializeCulture() method to the
Global.asax Application_BeginRequest(Object obj, EventArgs e)

2) Create a base-page class of which all your pages inherit from.
Implement the InitializeCulture() method in this base class. I
personally chose to use the 2nd option because I can't work with
cookies and I store this info in the user info in a session. And I
couldn't find a way to access the Session object from the
Applicaiton_BeginRequest() method.

Hope this helps.

BTW, can anybody tell me if this is a (best/good) practice?

Kind regards,

Jules
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top