Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
My site is localized. PLEASE help me create querystrings?
Old 01-29-2012, 10:42 PM My site is localized. PLEASE help me create querystrings?
jasonpaulweber's Avatar
Junior Talker

Posts: 2
Name: Jason Weber
Location: Detroit area, MI, USA
Trades: 0
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="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="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
jasonpaulweber is offline
Reply With Quote
View Public Profile Visit jasonpaulweber's homepage!
 
 
Register now for full access!
Old 01-30-2012, 03:38 PM Re: My site is localized. PLEASE help me create querystrings?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If the content language changes correctly, why does it matter?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-30-2012, 05:28 PM Re: My site is localized. PLEASE help me create querystrings?
jasonpaulweber's Avatar
Junior Talker

Posts: 2
Name: Jason Weber
Location: Detroit area, MI, USA
Trades: 0
Chris, you ask a simple question that I cannot even answer myself! I was just told by others that although my languages work, and that's wonderful and everything, that I should have querystrings like:

instead of: domain.com/default.aspx (when it's switched to German)
have: domain.com/default.aspx?lang=de
or, better: domain.com/DE/default.aspx

I was told this was better for SEO (duplicate content) purposes, as well as it helps end-users as far as helping 'em understand the website a little more. And it says on Google Webmaster Multilingual Sites to: "And last but not least, keep the content for each language on separate URLs - don't use cookies to show translated versions." ....

So those were the reasons, I suppose. I thought it'd be simple since I already have all the languages down, but it's proving to be a pain, and nobody really knows the answer. Thanks for reading my post though, Chris.

Jason Weber
jasonpaulweber is offline
Reply With Quote
View Public Profile Visit jasonpaulweber's homepage!
 
Old 01-31-2012, 04:27 AM Re: My site is localized. PLEASE help me create querystrings?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Take no notice of the blithering idiots! If it works correctly and you are happy with it leave it alone.

A: duplicate content CRAP! If it's in a different language how can it be duplicate?
B: Most users don't look at the URI

Quote:
And it says on Google Webmaster Multilingual Sites to: "And last but not least, keep the content for each language on separate URLs - don't use cookies to show translated versions."
True but they mean by using TLDs ie: domain.de (preferably) or subdirectories ie: domain.tld/de/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to My site is localized. PLEASE help me create querystrings?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.67959 seconds with 12 queries