|
|
Multilingual Site: Send The User To Page Of Choice | ||
Discussion by Alexandre Cisneiros with 6 Replies.
Last Update: April 22, 2006, 4:33 am | |||
CODE
<?php
// Enslish EUA
elseif ($HTTP_ACCEPT_LANGUAGE == "en-us"){
header("Location: index_eng.html");
}
// Inglкs UK
elseif ($HTTP_ACCEPT_LANGUAGE == "en-gb"){
header("Location: ingles_enuk.html");
}
// Portuguese [Brazil]
if ($HTTP_ACCEPT_LANGUAGE == "pt-br"){
header("Location: index_ptbr.html");
}
//German
elseif ($HTTP_ACCEPT_LANGUAGE == "de-de"){
header("Location: index_ger.html");
}
// Swedish
elseif ($HTTP_ACCEPT_LANGUAGE == "sv-se"){
header("Location: index_swe.html");
}
// French
elseif ($HTTP_ACCEPT_LANGUAGE == "fr-fr"){
header("Location: index_fre.html");
}
// Chinese
elseif ($HTTP_ACCEPT_LANGUAGE == "zh-cn"){
header("Location: index_chi.html");
}
// Thai
elseif ($HTTP_ACCEPT_LANGUAGE == "th-th"){
header("Location: index_tha.html");
}
?>
This is not a full tutorial, but just a little code snippet. Moved from [Tutorials > Programming > PHP] to [Programming > Scripting > PHP]
szupie
Now i saw that EDIT is disabled, so this is a correction:
CODE
CHANGE THE FIRSTS 3 IF's to this:///////////////////////////////////////////////////////
<?php
// Enslish EUA
if ($HTTP_ACCEPT_LANGUAGE == "en-us"){
header("Location: index_eng.html");
}
// Inglкs UK
elseif ($HTTP_ACCEPT_LANGUAGE == "en-gb"){
header("Location: ingles_enuk.html");
}
// Portuguese [Brazil]
elseif ($HTTP_ACCEPT_LANGUAGE == "pt-br"){
header("Location: index_ptbr.html");
}
////////////////////////////////////////////////////////
THE REST IS OK.
Mon Jan 23, 2006 Reply New Discussion
"en,lt;q=0.9,ru;q=0.8,de;q=0.7" ?
And using header is the last thing in this kind of type of script I would use.
Mon Jan 30, 2006 Reply New Discussion
Tue Jan 31, 2006 Reply New Discussion
QUOTE (Houdini)
Instead of using a bunch of elseif statements why not a CASE in a switch or even better, why not just have a drop down box or graphics that allow a user to choose the language themselves?Ok. Here is it:
CODE
switch ($HTTP_ACCEPT_LANGUAGE) {
case "en-us": header("Location: index_eng.html");
break;
case "en-uk": header("Location: index_enuk.html");
break;
case "pt-br": header("Location: index_ptbr.html");
break;
}
// ETC......
QUOTE
The reason you should not attempt to send some one to a particular language would be that they are on a computer that might not be their own and possibly if they are in another country while using that computer. On my sites you have 33 Flags representing 33 various languages that the user selects when coming to the site, and in my forums they can choose from 20 languages including English with two forms of Chinese and two forms of German. There they must of course choose the language themselves, but of course this is only if they are members since the only way to change your profile is to be a member.[view Post: 68329
You can add it on the site. Example:
QUOTE
AFTER REDIRECT, YOU CAN OUT THIS ON EACH PAGE://////////////////////////////////
Choose your language: [ box with langueages] [ Ok button]
Thu Feb 2, 2006 Reply New Discussion
to put that select box, when user gives his value,
CODE
<?php$lang=array(
'ru_text1' => 'Выполненная команда',
'ru_text2' => 'Выполнение команд на сервере',
'ru_text3' => 'Выполнить команду',
'ru_text4' => 'Рабочая директория',
'ru_text5' => 'Загрузка файлов на сервер',
'ru_text6' => 'Локальный файл',
'ru_text7' => 'Алиасы',
'ru_text8' => 'Выберите алиас',
'ru_butt1' => 'Выполнить',
'ru_butt2' => 'Загрузить',
'ru_text9' => 'Открытие порта и привязка его к /bin/bash',
'ru_text10' => 'Открыть порт',
'ru_text11' => 'Пароль для доступа',
'ru_butt3' => 'Открыть',
'eng_text1' => 'Executed command',
'eng_text2' => 'Execute command on server',
'eng_text3' => ' Run command',
'eng_text4' => 'Work directory',
'eng_text5' => 'Upload files on server',
'eng_text6' => 'Local file',
'eng_text7' => 'Aliases',
'eng_text8' => 'Select alias',
'eng_butt1' => 'Execute',
'eng_butt2' => 'Upload',
'eng_text9' => 'Bind port to /bin/bash',
'eng_text10' => 'Port',
'eng_text11' => 'Password for access',
'eng_butt3' => 'Bind'
);
//etc
//$language is choice of the user
print "$$language_text1;
//etc
?>
And print it when needed.
Sat Mar 18, 2006 Reply New Discussion
$HTTP_ vars are old, learn what's now and not in the past, no point in continuing with something deprecated.
The new variable is $_SERVER['HTTP_ACCEPT_LANGUAGE'];
Cheers,
MC
Sun Mar 19, 2006 Reply New Discussion
If someone wants to see this in action go to: Refugio de Santiago - New, is not finished yet and any comments or sugestions are welcome.
BTW i dont try the W3C standards, i gonna see later.
best regards,
Sat Apr 22, 2006 Reply New Discussion
Fopen Doesn't Work though I gave all permissions (5)
|
(2) Logging Items Entered Into A Textbox
|
Index




