Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Jan
    Jan is offline
    Regular Coder
    Join Date
    Jul 2002
    Location
    Finland
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Could someone please explain this to me?

    Hey again folks!

    I'm not sure if this thread is appropriate for this forum, but I will post it anyway. Well, I've just been wondering for some time now how a website with the address http://www.address.com/?page=home&lang=eng works? This is just an example, and I wondered if anyone could explain to me the structure of the website, and how it can be done. The reason why I'm asking this is because I'm making a website, that will be available in three different languages, and therefor this might be useful.

    Thanks!


    ~Jan

  • #2
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Jan,

    When Your question is: language depending web-site

    Take a look at www.dynamicdrive.com they have a so called language-sniffer

    Jerome

  • #3
    New Coder
    Join Date
    Feb 2003
    Location
    ROMANIA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, just for a general view, note that there must be a script that understand the info passed after the question mark and executes some functions or redirect the users based on that.

    Usually, that is a job for server side scripts (PHP, ASP, CGI).

    JS also understand what's after the "?", via the search property of the object location . You can access it like this:

    Code:
    <script language="JavaScript">
    
    if (window.location.search == 'lang=en')
      {
      text = english_text; 
    
    /*you defined the variable english_text earlier to contain the english version of text*/
                                       
      }
    
    else
     {
     text = polish_text;
    
    /*you defined the variable polish_text earlier to contain the polish version of text*/
     }
    
    
    
    document.write(text);
    
    </script>
    ...
    
    
    
    /* That's just a very simple example of how you can use JS for
    such a think like language change. Your link to the english version of the site will look like this:
    
     http://www.adres.com?lang=en
    The script above may save some work for you (you won't have to make a version of your html files for each language you use).

    If you have a lot of languages, use PHP instead; otherwise the user will have to wait until the ful text for ALL your languages load, so the script can pick the right one.

    See ya.
    Claudiu Iacob - Romania


  •  

    Posting Permissions

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