[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

idea to multi-lang site



hey, this is idea
create folder under name lang, this folder will include translation files... for example: ar.php and en.php
let look at en.php...
<?Php
$lang['dir'] = 'ltr';
$lang['welcome_msg'] = 'welcome to arabeyes';
?>
so ar.php can be like this...
<?Php
$lang['dir'] = 'rtl';
$lang['welcome_msg'] = 'marhaba ela arabeyes';
?>
and so on with other languages... next processor! to know which lang visitor like we have to detect by browser setiings... I guess you know about that! then add value to lang variable (cookie or url), in example below I'll use url method so can look like this: arabeyes.org/file.php?lang=ar
<?Php
// use next like to set value to $lang_file which get via url
// and as may notice I set "en" as default, to avoid errors
$lang_file = (isset($_GET['lang'])) ? $_GET['lang'] : 'en';


// include the file... in example will be ar.php... note url
include_once('lang/' .$lang_file. '.php');

// this is $lang['welcome_msg'] will be "marhaba ela arabeyes" because ar.php in included
// and will be "welcome to arabeyes" if en.php is included
print('<html dir="' .$lang['dir']. '">');
print($lang['welcome_msg']);
?>
that all!


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail