Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/translation/www/blog/wp-includes/theme.php on line 508
Vincent Park » 2007 » October » 02
Archive for October 2nd, 2007

How to use PEAR i18n library

October 02nd, 2007 | Category: Programming, Facebook

1. Download PEAR i18n package to your local machine

http://pear.php.net/packages.php?catpid=28&catname=Internationalization

2. Upload it to your server

3. Add the library path to php include_path using ini_set:

ini_set (”include_path”, “.:/www/facebook/pear:/usr/local/php5/lib/php”);

4. Use it

//loading PEAR I18Nv2
require_once ‘I18Nv2.php’;
require_once ‘I18Nv2/Locale.php’;
require_once ‘I18Nv2/Language.php’;

$i18nv2_lang = &new I18Nv2_Language($locale, ‘UTF-8′);
$i18nv2_locale = &I18Nv2::createLocale($locale);

- Getting translated language names

foreach ($i18nv2_lang->codes as $lang_code => $lang_translated) {

}

- Getting formatted date & time

$fdate= $i18nv2_locale->formatDate($time, I18Nv2_DATETIME_MEDIUM) ;
$ftime = $i18nv2_locale->formatTime($time, I18Nv2_DATETIME_MEDIUM);

No comments