My site is localized. PLEASE help me create querystrings?

I am not a programmer, but I managed to make my company’s website in 9 languages, using Visual Studio 2010 / VB / ASP.NET 4.0.

It’s a multilingual site, and I managed to put flags on the homepage. When I click a flag, the page’s text changes to that language. When you click the French flag, it gets the information from the "FR" .resx resource file in my apps_GlobalResources folder. Great! Well, not so great.

The URL, for instance, about.aspx, remains about.aspx. Granted, the text changes to French, but I’ve been told that it’s recommended to make it look like, if the client chooses French, for example, domain.com/about.aspx?lang=FR

But I have NO idea how to do this. If anybody can guide me clearly in the right direction, it’d be sincerely appreciated.

Jason Weber (For reference, if anybody is kind enough to delve into this issue, which may be a simple one, all of my files I’ve used in this are included below)

—-Homepage.master (how I’m calling the languages — just 2 samples)—–

Code:

      <asp:LinkButton ID="LinkButton6" runat="server"
      CommandArgument="de" OnClick="RequestLanguageChange_Click"
      class="flagbutton">     
      <asp:Image ID="Image7" runat="server" ImageUrl="~/images/flagde.png"
      tooltip="View this website in Deutsch" title="View this website in Deutsch"/>
      <img class="map" src="http://tycoontalk.freelancer.com/images/flaghoverde.png" alt=""/>
      </asp:LinkButton>
       
      <asp:LinkButton ID="LinkButton5" runat="server"
      CommandArgument="fr" OnClick="RequestLanguageChange_Click"
      class="flagbutton">     
      <asp:Image ID="Image6" runat="server" ImageUrl="~/images/flagfr.png"
      tooltip="Voir ce site en français" title="Voir ce site en français"/>
      <img class="map" src="http://tycoontalk.freelancer.com/images/flaghoverfr.png" alt=""/>
      </asp:LinkButton>


—————code behind homepage.master.vb———————

Code:

Partial Public Class Homepage
    Inherits System.Web.UI.MasterPage
    Protected Sub Page_Load(sender As Object, e As EventArgs)
    End Sub

    Protected Sub RequestLanguageChange_Click(sender As Object, e As EventArgs)
        Dim senderLink As LinkButton = TryCast(sender, LinkButton)

        'store requested language as new culture in the session
        Session(Udev.MasterPageWithLocalization.Classes.Global.SESSION_KEY_CULTURE) = senderLink.CommandArgument

        'reload last requested page with new culture
        Server.Transfer(Request.Path)
    End Sub
End Class


———————BasePage.vb in App_Code folder——————–

Code:

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Globalization
Imports System.Threading
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace Udev.MasterPageWithLocalization.Classes
    ''' <summary>
    ''' Custom base page used for all web forms.
    ''' </summary>
    Public Class BasePage
        Inherits Page
        Protected Overrides Sub InitializeCulture()
            'retrieve culture information from session
            Dim culture__1 As String = Convert.ToString(Session([Global].SESSION_KEY_CULTURE))

            'check whether a culture is stored in the session
            If culture__1.Length > 0 Then
                Culture = culture__1
            End If

            'set culture to current thread
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture__1)
            Thread.CurrentThread.CurrentUICulture = New CultureInfo(culture__1)

            'call base class
            MyBase.InitializeCulture()
        End Sub
    End Class
End Namespace


———————-Culture.vb in App_Code folder——————–

Code:

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace Udev.MasterPageWithLocalization.Classes
    ''' <summary>
    ''' This class provides ISO definitions for all cultures that are supported by this application.
    ''' </summary>
    Public Structure Culture
        'German - Switzerland definition
        Public Const DE As String = "de"
        'English - Great Britain definition
        Public Const EN As String = "en"
    End Structure
End Namespace


——————Global.vb in App_Code folder————————

Code:

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Namespace Udev.MasterPageWithLocalization.Classes
    ''' <summary>
    ''' Summary description for Global
    ''' </summary>
    Public Structure [Global]
        Public Const SESSION_KEY_CULTURE As String = "culture"
    End Structure
End Namespace


View full post on Tycoon Talk

, , , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved