locked
localization and database content problem RRS feed

  • Question

  • User-26774387 posted
    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:
    select news_id, date, title_nl, content_nl ......


    when the page is loaded in english the select statement should be:
    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:
    SelectCommand="Select date, title" + "<%$ Resources:Resource, LanguagePrefix %>" + " ... (and so on...)
     


    -LocalLocalization:
    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



     
     

      

     
     

     
    Sunday, April 23, 2006 5:38 AM

All replies

  • User1416329745 posted

    Try the links below the first is a three part article on localization and there is a link for Asp.net 2.0 localization resources in the second link.

    http://www.openmymind.net/index.aspx?documentId=52

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    http://www.codeproject.com/aspnet/LocalizedSamplePart2.asp

    <o:p> </o:p>

    <o:p> </o:p>

    <o:p> </o:p>

     

    Monday, April 24, 2006 12:36 PM
  • User-26774387 posted
    W00T

    thanks Caddre !!


    this is a life saver! I believe the second link will help me a lot!
    I was clearly going for the bad design (each table having the dutch and english content)

    I'm going to try this out ;)


    Monday, April 24, 2006 1:34 PM
  • User1416329745 posted
    Thanks I am glad I could help.
    Monday, April 24, 2006 2:11 PM
  • User423742572 posted

    If you wish, you can see it in action, checj this thread and dowload the zip file... http://forums.asp.net/thread/988589.aspx

    See Resource and LocalizedResource in the BLL classes
    Or drop me a mail, i'll send you localized classes samples
    You can just adapt it to your News class...

    Enjoy [;)]

    Luc from Brussels

     

    Tuesday, April 25, 2006 10:57 AM
  • User-26774387 posted
    thank you luc ;)

    I've read everything.
    I went through the 3 articles (part 1 to 3) and I understand the advantage when developing it like that.


    However the website I'm making for a client is't that hugue and using the default localisation principles given by ASP.NET 2.0 would be more than sufficient for my static content. (translation of all the labels)

    What was the most interesting part was the new DB design with the culture table. It's indeed much better to design the db like that. I knew I didn't like my initial design.
    in the new design, the select statement would be quite easy due to the stored procedure which will go look what culture is being used.
    However I'm a bit sceptical about the level of complexity for the admin part of the website where all the inserts, updates must be done.

    Doing the design like this will require the admin of the website to ALWAYS insert both translations for a certain item into the _locale tables otherwise for a cetain language the website will display quite a few blanks.


    since I'm using ASP.NET 2.0, I'm thinking to only use the db part of the article and leave out the costum ResourceManager...
    or would you recommend doing that too ?


    thank you



    Wednesday, April 26, 2006 4:18 AM
  • User423742572 posted

    Sorry for late answer, i was not able to connect the forum anymore [:^)]

    That's always the problem with localized websites, the customer need and want many languages, but never translate it...
    As for the blanks when locales are not translated,  the resource manager displays the default culture value if no locale exists... see ResourceManager.GetResource, all default values are loaded first.

    For other ojects with localized values, I always use  DB select statements with "SELECT CASE" to return the defautl culture translation if no localized value exist... no blanks here neither..

    I now use this localization module in asp.net 2, and it work like a charm (with 9 translators working on it)... i put far more than simple labels in it.
    If your website is small, may the DB Resourcemanager only could suffice ?


    It just miss a image manager to upload pictures and i would use it as a static pages editor (next step)

    Rgds,

    Luc

     

     

    Friday, June 16, 2006 9:06 AM
  • User423742572 posted

    If you did not install it yet, you may want to read that for asp.net 2 custom localization

    http://www.codeproject.com/aspnet/customsqlserverprovider.asp
    http://www.leftslipper.com/ShowFaq.aspx?FaqId=9

    Enjoy ;o)

    Saturday, June 17, 2006 3:55 AM