language ???

Last post 04-08-2007 2:25 PM by tyaramis. 4 replies.

Sort Posts:

  • language ???

    03-16-2005, 12:48 AM
    • Loading...
    • vuongxx
    • Joined on 03-09-2005, 10:49 PM
    • Posts 28
    i want my website can be viewed in two language.
    I don't know how people use to do this.
    Any good way ??
  • Re: language ???

    03-17-2005, 7:10 AM
    • Loading...
    • mbanavige
    • Joined on 11-06-2003, 8:29 AM
    • New England, USA
    • Posts 7,705
    • Moderator
      TrustedFriends-MVPs
    There are two common methods.

    1) create a set of pages per language.
    2) load all text into your controls programatically

    i prefer option 2

    If you choose option 2, you need to store the translations for every piece of text you are going to display.
    There are several common options.

    1) use a resource file that compiles to a satellite assembly
    2) put them in a regular xml file
    3) put them in a database

    I prefer option 3 for web apps as i find it easier to administer (i.e. i can easily delegate the administration to a non programmer)

    once you've gotten your translation where they need to be stored, you need to be able to set your UI elements to display the translated text.
    Text from resource files can be retrieved by its key using a ResourceManager object
    Text from an XML file or DB needs a custom retrieval method.
    I created a custom GetText function to mimick the method in the built in ResourceManager object.

    Text from a DB should be cached for performance reasons.
    I prefer to cache the DB translations in a case-insensitive HashTable.

    With the infrastructure in place, you also need to know which language to display.
    Once again there are a couple options.

    1) Let the user choose by clicking on something
    2) Detect it from the Browsers Languages collection (which may have multiple entries)

    I prefer option 2. when i am unable to detect a languge for which i have translations i drop back to english.

    Now we're ready to display a translation

    myLabel.Text = GetText(myTranslationKey, myDefaultEnglishString)




    Mike Banavige
    ~~~~~~~~~~~~
    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: language ???

    04-08-2007, 1:22 PM
    • Loading...
    • tyaramis
    • Joined on 06-12-2006, 5:52 AM
    • Posts 4

    Hi

    your are right, with this way, you can easily maintain your translates and change your captions in your web site dynamically.

    But I have another problem about generating multi-language web site. How did you strore the content of your web site in DB?

    Lets assume, I have a page in my web site that is called "News".

    in Db, there is a table for that which design smth like this

    NewsID int (PK),

    NewsTitle (nvarchar(50),

    NewsDesc (250)

    and in my admin panel of my site, I am entering news and storing them in this table. But I want to enter the news in 3 Languages. German, English, French

    How should I design this table or a new table to achive my multi langauge news page?

    I think, doing this in News table is not a good idea. For exampe NewsDescGerman,  NewsDescEnglish ...

    Can you give me an better idea about this?

    Thanks alot.

     

  • Re: language ???

    04-08-2007, 1:48 PM
    • Loading...
    • vivek_iit
    • Joined on 06-18-2006, 6:13 PM
    • New Delhi
    • Posts 3,072
    • TrustedFriends-MVPs

    You can check the last part of this article where I talk about a database based approach:

    http://www.codeproject.com/useritems/localization.asp

    Hope this helps,

    Vivek 

    MVP, ASP.NET || My Website || Blog || Articles

    Please mark the most helpful reply/replies as "Answer".
  • Re: language ???

    04-08-2007, 2:25 PM
    • Loading...
    • tyaramis
    • Joined on 06-12-2006, 5:52 AM
    • Posts 4

    Thats the idea what I was looking for..

    Thanks alot.

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter