.

GyroLocale Class Reference
[Lib]

Manages Encoding and languages. More...

List of all members.

Static Public Member Functions

static  get_charset ()
  Returns current charset.
static  get_language ()
  Returns current language.
static  get_locales ($lang)
  Returns array of possible locales for a language.
static  is_utf8 ()
  Returns true, if charset is UTF-8.
static  set_charset ($charset)
  Sets charset, but does not affect locale.
static  set_language ($lang)
  Sets language, but does not affect locale.
static  set_locale ($lang, $charset=APP_CHARSET)
  Set an according locale (used for date, and number formatting).

Public Attributes

const  UTF8 = 'UTF-8'

Detailed Description

Manages Encoding and languages.

Author:
Gerd Riesselmann

Definition at line 8 of file locale.cls.php.


Member Function Documentation

static GyroLocale::get_charset (  )  [static]

Returns current charset.

Returns:
string

Definition at line 101 of file locale.cls.php.

00101                                              {
00102                 return self::$charset;
00103         }
static GyroLocale::get_language (  )  [static]

Returns current language.

Returns:
string

Definition at line 92 of file locale.cls.php.

00092                                               {
00093                 return self::$language;
00094         }
static GyroLocale::get_locales ( lang  )  [static]

Returns array of possible locales for a language.

E.g. for "en" would return "en_US", "en"

Parameters:
string  $lang
Returns:
array

Definition at line 49 of file locale.cls.php.

00049                                                   {
00050                 $ret = array();
00051                 if (strlen($lang) == 2) {
00052                         switch ($lang) {
00053                         case 'en':
00054                                 $ret[] = 'en_US';
00055                                 $ret[] = 'en_GB';
00056                                 break;
00057                         default:
00058                                 // add xx_XX
00059                                 $ret[] = $lang . '_' . strtoupper($lang);
00060                                 break;
00061                         }
00062                 }
00063                 $ret[] = $lang;
00064                 return $ret;            
00065         }
static GyroLocale::is_utf8 (  )  [static]

Returns true, if charset is UTF-8.

Definition at line 108 of file locale.cls.php.

00108                                          {
00109                 return strtoupper(self::get_charset()) == self::UTF8;                   
00110         }
static GyroLocale::set_charset ( charset  )  [static]

Sets charset, but does not affect locale.

Parameters:
string  $charset

Definition at line 83 of file locale.cls.php.

00083                                                      {
00084                 self::$charset = $charset;
00085         }
static GyroLocale::set_language ( lang  )  [static]

Sets language, but does not affect locale.

Returns old lang

Parameters:
string  $lang

Definition at line 72 of file locale.cls.php.

00072                                                    {
00073                 $ret = self::$language;
00074                 self::$language = $lang;
00075                 return $ret;
00076         }
static GyroLocale::set_locale ( lang,
charset = APP_CHARSET  
) [static]

Set an according locale (used for date, and number formatting).

Sets language and charset, too

Parameters:
string  $lang Language, like 'en', or 'en_US'
string  $charset A Charset like "latin1" or "UTF-8"

Definition at line 22 of file locale.cls.php.

00022                                                                          {
00023                 self::set_language($lang);
00024                 self::set_charset($charset);
00025                 
00026                 $locales = self::get_locales($lang);
00027                 $locales_encoded = array();
00028                 $encoding = strtolower(str_replace('-', '', $charset));
00029                 foreach($locales as $l) {
00030                         $locales_encoded[] = $l . '.' . $encoding;
00031                 }
00032                 setlocale(LC_ALL, array_merge($locales_encoded, $locales));
00033                 if (strtolower($lang) == 'en_us') {
00034                         GyroDate::$local_date_order = GyroDate::MONTH_DAY_YEAR;
00035                 }
00036                 else {
00037                         GyroDate::$local_date_order = GyroDate::DAY_MONTH_YEAR;
00038                 }
00039         }

Member Data Documentation

const GyroLocale::UTF8 = 'UTF-8'

Definition at line 9 of file locale.cls.php.


The documentation for this class was generated from the following file: