* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBDictionary' , 'WBString'); /** * Dictionary: Country * * Manage two letter country codes * * @version 0.1.1 * @package WB * @subpackage */ class WBDictionary_Language extends WBDictionary { /** * list of codes and names * @var array */ protected static $list = array(); /** * 2nd constructor * * load county codes and translate names */ public function init() { if (!empty(self::$list)) { return; } // initi list only once WBClass::create('patI18n'); self::$list = array( 'ab'=> patI18n::dgettext('wombat','Abkhazian'), 'aa'=> patI18n::dgettext('wombat','Afar'), 'af'=> patI18n::dgettext('wombat','Afrikaans' ), 'sq'=> patI18n::dgettext('wombat','Albanian' ), 'am'=> patI18n::dgettext('wombat','Amharic' ), 'ar'=> patI18n::dgettext('wombat','Arabic' ), 'hy'=> patI18n::dgettext('wombat','Armenian' ), 'as'=> patI18n::dgettext('wombat','Assamese' ), 'ay'=> patI18n::dgettext('wombat','Aymara' ), 'az'=> patI18n::dgettext('wombat','Azerbaijani' ), 'ba'=> patI18n::dgettext('wombat','Bashkir' ), 'eu'=> patI18n::dgettext('wombat','Basque' ), 'bn'=> patI18n::dgettext('wombat','Bengali' ), 'dz'=> patI18n::dgettext('wombat','Bhutani' ), 'bh'=> patI18n::dgettext('wombat','Bihari' ), 'bi'=> patI18n::dgettext('wombat','Bislama' ), 'br'=> patI18n::dgettext('wombat','Breton' ), 'bg'=> patI18n::dgettext('wombat','Bulgarian' ), 'my'=> patI18n::dgettext('wombat','Burmese' ), 'be'=> patI18n::dgettext('wombat','Byelorussian' ), 'km'=> patI18n::dgettext('wombat','Cambodian' ), 'ca'=> patI18n::dgettext('wombat','Catalan' ), 'zh'=> patI18n::dgettext('wombat','Chinese' ), 'co'=> patI18n::dgettext('wombat','Corsican' ), 'hr'=> patI18n::dgettext('wombat','Croatian' ), 'cs'=> patI18n::dgettext('wombat','Czech' ), 'da'=> patI18n::dgettext('wombat','Danish' ), 'nl'=> patI18n::dgettext('wombat','Dutch' ), 'en'=> patI18n::dgettext('wombat','English' ), 'eo'=> patI18n::dgettext('wombat','Esperanto' ), 'et'=> patI18n::dgettext('wombat','Estonian' ), 'fo'=> patI18n::dgettext('wombat','Faeroese' ), 'fa'=> patI18n::dgettext('wombat','Farsi' ), 'fj'=> patI18n::dgettext('wombat','Fiji' ), 'fi'=> patI18n::dgettext('wombat','Finnish' ), 'fr'=> patI18n::dgettext('wombat','French' ), 'fy'=> patI18n::dgettext('wombat','Frisian' ), 'gd'=> patI18n::dgettext('wombat','Gaelic' ), //'gv'=> patI18n::dgettext('wombat','Gaelic' ), 'gl'=> patI18n::dgettext('wombat','Galician' ), 'ka'=> patI18n::dgettext('wombat','Georgian' ), 'de'=> patI18n::dgettext('wombat','German' ), 'el'=> patI18n::dgettext('wombat','Greek' ), 'kl'=> patI18n::dgettext('wombat','Greenlandic' ), 'gn'=> patI18n::dgettext('wombat','Guarani' ), 'gu'=> patI18n::dgettext('wombat','Gujarati' ), 'ha'=> patI18n::dgettext('wombat','Hausa' ), 'he'=> patI18n::dgettext('wombat','Hebrew' ), 'hi'=> patI18n::dgettext('wombat','Hindi' ), 'hu'=> patI18n::dgettext('wombat','Hungarian' ), 'is'=> patI18n::dgettext('wombat','Icelandic' ), 'id'=> patI18n::dgettext('wombat','Indonesian' ), 'ia'=> patI18n::dgettext('wombat','Interlingua' ), 'ie'=> patI18n::dgettext('wombat','Interlingue' ), 'iu'=> patI18n::dgettext('wombat','Inuktitut' ), 'ik'=> patI18n::dgettext('wombat','Inupiak' ), 'ga'=> patI18n::dgettext('wombat','Irish' ), 'it'=> patI18n::dgettext('wombat','Italian' ), 'ja'=> patI18n::dgettext('wombat','Japanese' ), 'jv'=> patI18n::dgettext('wombat','Javanese' ), 'kn'=> patI18n::dgettext('wombat','Kannada' ), 'ks'=> patI18n::dgettext('wombat','Kashmiri' ), 'kk'=> patI18n::dgettext('wombat','Kazakh' ), 'rw'=> patI18n::dgettext('wombat','Kinyarwanda' ), 'ky'=> patI18n::dgettext('wombat','Kirghiz' ), 'rn'=> patI18n::dgettext('wombat','Kirundi' ), 'ko'=> patI18n::dgettext('wombat','Korean' ), 'ku'=> patI18n::dgettext('wombat','Kurdish' ), 'lo'=> patI18n::dgettext('wombat','Laothian' ), 'la'=> patI18n::dgettext('wombat','Latin' ), 'lv'=> patI18n::dgettext('wombat','Latvian' ), 'li'=> patI18n::dgettext('wombat','Limburgish' ), 'ln'=> patI18n::dgettext('wombat','Lingala' ), 'lt'=> patI18n::dgettext('wombat','Lithuanian' ), 'mk'=> patI18n::dgettext('wombat','Macedonian' ), 'mg'=> patI18n::dgettext('wombat','Malagasy' ), 'ms'=> patI18n::dgettext('wombat','Malay' ), 'ml'=> patI18n::dgettext('wombat','Malayalam' ), 'mt'=> patI18n::dgettext('wombat','Maltese' ), 'mi'=> patI18n::dgettext('wombat','Maori' ), 'mr'=> patI18n::dgettext('wombat','Marathi' ), 'mo'=> patI18n::dgettext('wombat','Moldavian' ), 'mn'=> patI18n::dgettext('wombat','Mongolian' ), 'na'=> patI18n::dgettext('wombat','Nauru' ), 'ne'=> patI18n::dgettext('wombat','Nepali' ), 'no'=> patI18n::dgettext('wombat','Norwegian' ), 'oc'=> patI18n::dgettext('wombat','Occitan' ), 'or'=> patI18n::dgettext('wombat','Oriya' ), 'ps'=> patI18n::dgettext('wombat','Pashto' ), 'pl'=> patI18n::dgettext('wombat','Polish' ), 'pt'=> patI18n::dgettext('wombat','Portuguese' ), 'pa'=> patI18n::dgettext('wombat','Punjabi' ), 'qu'=> patI18n::dgettext('wombat','Quechua' ), 'rm'=> patI18n::dgettext('wombat','Rhaeto-Romance' ), 'ro'=> patI18n::dgettext('wombat','Romanian' ), 'ru'=> patI18n::dgettext('wombat','Russian' ), 'sm'=> patI18n::dgettext('wombat','Samoan' ), 'sg'=> patI18n::dgettext('wombat','Sangro' ), 'sa'=> patI18n::dgettext('wombat','Sanskrit' ), 'sr'=> patI18n::dgettext('wombat','Serbian' ), 'sh'=> patI18n::dgettext('wombat','Serbo-Croatian' ), 'st'=> patI18n::dgettext('wombat','Sesotho' ), 'tn'=> patI18n::dgettext('wombat','Setswana' ), 'sn'=> patI18n::dgettext('wombat','Shona' ), 'sd'=> patI18n::dgettext('wombat','Sindhi' ), 'si'=> patI18n::dgettext('wombat','Sinhalese' ), 'ss'=> patI18n::dgettext('wombat','Siswati' ), 'sk'=> patI18n::dgettext('wombat','Slovak' ), 'sl'=> patI18n::dgettext('wombat','Slovenian' ), 'so'=> patI18n::dgettext('wombat','Somali' ), 'es'=> patI18n::dgettext('wombat','Spanish' ), 'su'=> patI18n::dgettext('wombat','Sundanese' ), 'sw'=> patI18n::dgettext('wombat','Swahili' ), 'sv'=> patI18n::dgettext('wombat','Swedish' ), 'tl'=> patI18n::dgettext('wombat','Tagalog' ), 'tg'=> patI18n::dgettext('wombat','Tajik' ), 'ta'=> patI18n::dgettext('wombat','Tamil' ), 'tt'=> patI18n::dgettext('wombat','Tatar' ), 'te'=> patI18n::dgettext('wombat','Telugu' ), 'th'=> patI18n::dgettext('wombat','Thai' ), 'bo'=> patI18n::dgettext('wombat','Tibetan' ), 'ti'=> patI18n::dgettext('wombat','Tigrinya' ), 'to'=> patI18n::dgettext('wombat','Tonga' ), 'ts'=> patI18n::dgettext('wombat','Tsonga' ), 'tr'=> patI18n::dgettext('wombat','Turkish' ), 'tk'=> patI18n::dgettext('wombat','Turkmen' ), 'tw'=> patI18n::dgettext('wombat','Twi' ), 'ug'=> patI18n::dgettext('wombat','Uighur' ), 'uk'=> patI18n::dgettext('wombat','Ukrainian' ), 'ur'=> patI18n::dgettext('wombat','Urdu' ), 'uz'=> patI18n::dgettext('wombat','Uzbek' ), 'vi'=> patI18n::dgettext('wombat','Vietnamese' ), 'vo'=> patI18n::dgettext('wombat','Volapuk' ), 'cy'=> patI18n::dgettext('wombat','Welsh' ), 'wo'=> patI18n::dgettext('wombat','Wolof' ), 'xh'=> patI18n::dgettext('wombat','Xhosa' ), 'yi'=> patI18n::dgettext('wombat','Yiddish' ), 'yo'=> patI18n::dgettext('wombat','Yoruba' ), 'zu'=> patI18n::dgettext('wombat','Zulu' ) ); natsort(self::$list); } /** * find entry in dictionary * * Just a dummy * * @param array $data * @return array|null */ protected function find($data) { return null; } /** * load record by id * * map code to language names etc * * @param string $id */ public function load($id) { if ($this->id == $id) { return; } if ('c' == strtolower($id)) { $id = 'en_US'; } $data = array(); // utilize county code dictionary for second part if (strlen($id) == 5) { $cid = strtolower(substr($id, 3)); $country = WBClass::create('WBDictionary_Country'); $country->load($cid); $data = $country->get(); } else if (strlen($id) != 2) { WBClass::load('WBException_Argument'); throw new WBException_Argument('Language code must be either two letter (de) or five letter code (de_DE)!', 2, __CLASS__); } $short = substr($id,0, 2); if (!isset(self::$list[$short])) { WBClass::load('WBException_Argument'); throw new WBException_Argument('Invalid language code "'.$short.'"!', 1, __CLASS__); } $this->id = $id; $this->word = self::$list[$short]; $this->data = array( 'populated' => true, 'id' => $id, 'languagecode' => $short, 'languagename' => $this->word ); // merge with country data $this->data = array_merge($data, $this->data); } /** * extract dictionary data from word * * Just to satify the interface * * @see include/WB/WBDictionary#explode() * @param string $word * @return array */ protected function explode($word) { return array('name' => $word); } /** * add record to dictionary * * This is just a fake. Insert is not allowed * * @see include/WB/WBDictionary#insert() * @param array record to save * @return string record id */ protected function insert($data) { return null; } /** * save additional data to dictionary record * * This is just a fake - merge is not required * * @see populate() * @see $mergeFields * @param array $data * @return array */ protected function merge($save) { return $save; } /** * automatical populate function * * Surf to URL and extract title, description as well as * * @param string $id * @see include/WB/WBDictionary#autoPolulate() */ public function autoPopulate($id = null) { } /** * get list of dictionary records * * Get all languages * * @return array $list */ public function getList() { return self::$list; } } ?>