1.

Solve : Localized page?

Answer»

Hello,

I would like to know how to detect the LANGUAGE of the computer that the visitor is using and depending on the language go to a certain page.

Thanks

Al968There are several different ways to do this. The Apache web server has the feature built in, so when configured correctly, English users will be redirected to, say, index.html.en, and German users will be redirected to index.html.de.

Or you can do the detection via server side scripting. What's your setup?I don't know my setup so I would rather do it by server side scripting, however may I ask which language does it require ? Php or something ELSE ?

Thanks

Al968I can only tell you about PHP, since that's my coding language of preference. But the principle should apply to any server-side scripting that can inspect headers.

The $_SERVER['HTTP_ACCEPT_LANGUAGE'] variable should tell you what locale the user's browser is reporting, and you can adjust your response accordingly (with a select statement or whatever).There are also javascripts that could be used to detect language and forward users according to language to the appropriate location.

Below is a link to an example I found doing a quick search in Google for "JAVASCRIPT language detect script"

http://www.javascriptkit.com/script/script2/language.shtml

Javascript can just be inserted into your HTML.Quote

I can only tell you about PHP, since that's my coding language of preference. But the principle should apply to any server-side scripting that can inspect headers.

The $_SERVER['HTTP_ACCEPT_LANGUAGE'] variable should tell you what locale the user's browser is reporting, and you can adjust your response accordingly (with a select statement or whatever).

Thanks, Can you be more precice as I don't know Php at all, maybe a tutorial ?

Thanks

Al968This would be a somewhat ADVANCED thing to do in any language, so it would help to use a language that you're already familiar with - or if you haven't used one before, consider doing a basic tutorial first.

I can give you some code, but you'll need a handle on how to use it. How would you like to proceed?I think that I can handle the basics (I may be WRONG) so you go ahead and give me the code ?

Thank You for your help

Al968An example, anywhere in your HTML.

Code: [Select]<?php
switch($_SERVER['HTTP_ACCEPT_LANGUAGE'])
{
case'de':
echo'Willkommen';
break;
case'es':
echo'Recepción';
break;:
case'fr'
echo'Bienvenue';
break;
case'it':
echo'Benvenuto';
break;
default:
echo'Welcome';
}
?>


Discussion

No Comment Found