whats the best way to have multiple language asp pages?

Discussion in 'ASP General' started by mike, Sep 14, 2005.

  1. mike

    mike Guest

    Hello all,

    any advice or links to pages about how to have multiple language asp
    pages? For example, you have a database driven website that you want
    customers around the world to use. How do you setup the asp pages so
    that it is easy to change the text based on where the user is
    connecting from?

    Thanks,
    Mike
     
    mike, Sep 14, 2005
    #1
    1. Advertisements

  2. mike

    Mr Beaton Guest

    Mike,
    There are several aspects to this. One of which is how/if you automatically
    will determine the users locale (like much of microsoft.com does, for
    instance), or if you will present a specific language and allow the user to
    choose from other languages as he or she pleases. One other aspect is how to
    present the correct information based on the users locale or choise. I'll
    give you a few pointers on the latter part;

    Normally when I start designing a multilanguage site, I start with paper and
    pencil, and establish an overview of how the database needs to be designed.
    The content and functionality of the site sets the boundaries for this. In a
    very simplified version, let's say that the page's build, the layout,
    positioning of images, etc. etc. are all done in the asp page. The only data
    you store in the database (as far as this example goes, is the acctual text
    (and, prehaps, some formatting) of the document. My table handling this
    would look something like the following:

    tblPages:
    fldID, integer, identity, auto increment, no nulls, no duplicates (this
    field is only needed if you require a unique identifier, or a primary key)
    fldName, (var)char, [size according to preference], no nulls, allow
    duplicates
    fldContents, (var)char, [size according to preference],no nulls, allow
    duplicates (not likely to have duplicates, but nevertheless)
    fldLanguage, (var)char, [size according to preference (you should only need
    two characters, but maybe the language name is more descriptive)], no nulls,
    allow duplicates

    That is a VERY simplified table, but it would do the trick. Now, using
    whatever method you deem fitting, you either temporary (session variable) or
    semi-permanently (cookie) store a variable determining the users prefered
    language, or in the event that you need support for browsers/users that do
    not allow for cookies, pass a variable with every page request. This
    variable allows for filtering what content to provide in the asp page. The
    SQL could look like

    "SELECT fldContent FROM tblPages WHERE fldName = '" &
    strNameOfContentYouRequest & "' AND fldLanguage = '" & strLanguageVariable &
    "'"

    Again, this is a gravely simplified query, it does not protect against SQL
    injection, and so on. But I hope it gives the general idea. In the database
    table, you might want to add colunms for createdDate, validFrom, validTo,
    contentActive, and so on, depending on the complexity of the application.

    HTH,

    //Leif Beaton
     
    Mr Beaton, Sep 15, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.