Results 1 to 5 of 5

Thread: Localization in asp.net 2.0

  1. #1
    Join Date
    Nov 2005
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Localization in asp.net 2.0

    Hello,

    A client of mine wants a website supporting 2 languages. (English and Dutch)
    Currently I've worked out all the static content with labels pointing to LocalResources and GlobalResources.
    It works great. If I change my language in my browser, the content dynamically changes to the prefered language.
    Now all that I need to do is make a dropdown so that the user can override their browser preference. I also want to store this preference into a cookie and the profile.

    But I do however have a problem with the content being read out of the database.
    All my tables have dual language support.

    example: the Table NEWS contains the rows: new_id, date, title_nl, title_en, content_nl, content_en


    Is there a way so let the page generate the specific row when loading the page with a specific culture.
    In other words:

    when the page is loaded in dutch the select statement should be:
    Code:
    select news_id, date, title_nl, content_nl ......
    when the page is loaded in english the select statement should be:
    Code:
    select news_id, date, title_en, content_en ....


    I tried to use local en global localization like this:
    in the localization file a field LanguagePrefix with either "_nl" or "_en"


    -GlobalLocalization:
    Code:
    SelectCommand="Select date, title" + "<%$ Resources:Resource, LanguagePrefix %>" + " ... (and so on...)

    -LocalLocalization:
    Code:
    SelectCommand="Select date, title"+meta:resourceKey="LanguagePrefix"+"... (and so on...)


    this however doesn't work. Any ideas on how to get this done ?



    an alternative option would be to simple make 2 folders: /EN and /NL
    and have a seperate page for either /EN and /NL but frankly I don't like this solution because I don't see the use of localization features in this context. (ie. duplicate pages, and so on...)



    tips are very welcome


    thanks

  2. #2
    Join Date
    Oct 2005
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Use an HttpHandler up front that sucks the /NL/ /EN/ bit off the URL, removes it and sets the context thread locale accordingly.

    You MUST have this in the URL ALL THE TIME as search engine crawlers will randomly index the wrong language and you'll lose hits because some pages will not get indexed based on the language selection being different.

    Hope this helps!

  3. #3
    Join Date
    Nov 2005
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm afraid I don't quite follow here...

    remove the /NL en /EN bit off the url?

    currently I don't have NL or/and /EN folders.
    I have 1 website with for each page only 1 version. The languages are changed dynamically through culture settings and the Resources files.

    but I'm looking for a way to use specific select statements for either the NL culture or EN culture without having to have 2 different version for the website (in 2 different folders, EN en NL)

    I hope this is a bit clearer

  4. #4
    Join Date
    Oct 2005
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok. Let me explain a bit clearer (I am at fault - it was late!). You only need the web site in one directory.

    The procedure I described means that the application will have a different URL, but NOT a different directory for each language. An HttpModule will be inserted into the application that would rewrite the following URL:

    http://site/NL/Default.aspx ... to ... http://site/Default.aspx

    At the same time you would save the NL or EN part of the URL in the HttpContext as HttpContext.Current.Items["Language"] = "EN" .. you can then refer to this in the subsequent pages and SQL statements at will to determine the language and set the thread locale to your localised language.

    The HttpModule will also be responsible for determining the browser's inital locale and switching the site accordingly by redirecting from Default.aspx to /NL/Default.aspx as well.

    The reason to do it this way is that there must be a physical separation of different languages at the URL level due to the way search engines work.

  5. #5
    Join Date
    Nov 2005
    Posts
    137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you for the tip...

    I found an article that might help:

    http://www.codeproject.com/aspnet/Lo...amplePart2.asp

    they also mention using url rewriting

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ASP.NET book
    By creativeworks in forum ASP.NET
    Replies: 4
    Last Post: 7th February 2006, 02:28 PM
  2. Does asp.net have something against afghanisatn?
    By jaimalchohan in forum ASP.NET
    Replies: 12
    Last Post: 25th November 2005, 12:58 PM
  3. asp.net db connection
    By creativeworks in forum ASP.NET
    Replies: 34
    Last Post: 8th November 2005, 03:53 PM
  4. ASP.net 2.0
    By JohnnyW in forum Sales and Service Feature Enquiries
    Replies: 17
    Last Post: 8th November 2005, 01:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •