From: Carsten K. <car...@ma...> - 2001-12-07 22:53:52
|
I found a code snippet demonstrating how to automatically determine the default language selected in a user's browser. May be useful for offering a default language choice in the user preferences. Carsten <?php // language codes are comma delimited $lang = strtok ( $HTTP_ACCEPT_LANGUAGE, "," ); while ( $lang ) { //if there is "en" in it if ( strstr ( $lang, "en" ) ) { header ( "Location: http://localhost/english/" ); exit; } if ( strstr ( $lang, "es" ) ) { header ( "Location: http://localhost/castellano/" ); exit; } if ( strstr ( $lang, "nl" ) ) { header ( "Location: http://localhost/nederlands/" ); exit; } if ( strstr ( $lang, "de" ) ) { header ( "Location: http://localhost/deutsch/" ); exit; } $lang = strtok( "," ); } //next token and end of while // default relocation in case nothing got detected header ("Location: http://localhost/english/"); exit; ?> On Wednesday, November 28, 2001, at 11:40 am, Jeff Dairiki wrote: > On Wed, 28 Nov 2001 10:08:36 +0000 > "Lawrence Akka" <la...@20...> wrote: > >> A few thoughts - >> >> 1) The language of the interface should be user-selectable. Just > because >> the [web|wiki]master has decided to set the locale as Italian, doesn't > mean >> that everyone wants to see Italian links/instructions. > > Yes, once we have real users and user preferences, that's probably a fine > idea. > |