Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (26 May 2013 - 08:25 AM) And Need Some Suggestion To Start A Ball Roll Here.
@  agyat : (26 May 2013 - 08:24 AM) Nothing Special For The Day. What About You?
@  yordan : (25 May 2013 - 09:50 PM) Hi, Agyat What's New?
@  yordan : (25 May 2013 - 07:59 PM) Yay, Shoutbox Is Back! Yahooo!
@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.

Replying to Multilingual Site: Send The User To Page Of Choice


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

TavoxPeru

Posted 22 April 2006 - 04:33 AM

Hi, one of my clients need to translate his website to english -is in spanish- because he wants to capture more clients, so after investigating and testing different solutions i find that the simplest way to do this is by using a session variable that holds the default/user language, some files for each translation and the use of associative arrays.

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,

mastercomputers

Posted 19 March 2006 - 01:32 PM

Why not just listen to W3C Standards for the correct method of doing this without any dynamic scripting involved. It makes sense considering there's tonnes of languages, that to write a line of code for each one, does not make any sense. If you develop alternative pages in different languages then I suggest you read W3C on how it should be handled and not rely on what device connects to you, because it's possible they don't have an ACCEPT_LANGUAGE and you have not set a default for if it doesn't match. Also what someone said with the ACCEPT_LANGUAGE having a mixed string, since you can have it set up by preference, including the language that you prefer, but if you're not checking for their preferred language and only one that they've set, then you're definitely better off using W3C's way.

$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

CrazyPensil

Posted 18 March 2006 - 08:11 AM

Actually, the way of redirect is quite a silly and takes a lot of place on the server.

to put that select box, when user gives his value,

<?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' => '&nbsp;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.

Alexandre Cisneiros

Posted 02 February 2006 - 09:25 PM

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

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


You can add it on the site. Example:

AFTER REDIRECT, YOU CAN OUT THIS ON EACH PAGE:
//////////////////////////////////
Choose your language: [ box with langueages] [ Ok button]


Houdini

Posted 31 January 2006 - 12:16 AM

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

Quatrux

Posted 30 January 2006 - 08:27 PM

What about if I do not want to go to my browser set language ? and have you seen what kind of ACCEPT LANGUAGE most of the browsers send ? I usually set a lot, like, how would your script work with this ?

"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. :)

Alexandre Cisneiros

Posted 23 January 2006 - 02:29 AM

If you have one site in diferent laanguages, this simple script can redirect the user to the correct page acording to his/her language:


<?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:

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.

Review the complete topic (launches new window)