...

View Full Version : Could someone please explain this to me?



Jan
02-28-2003, 10:37 AM
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

Jerome
02-28-2003, 10:49 AM
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

claudiuiacob
02-28-2003, 11:12 AM
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:



<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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum