Location: PHPKode > projects > Artise > artise/environment/lang/lang.class.php
<?php
 namespace Env\xLang; class xLang extends \Ext\Source\Instances { private $path, $active_lang = false, $manifest = false; static public $instance; public function manifest($lang = false) { $this->cs_manifest(); if ($lang !== false) return in_array($lang, $this->manifest); return new \Readers\Listing($this->manifest); } public function active() { return $this->active_lang; } public function &__call($function, $args) { return $this->lang($function); } public function phrase($phrase, $vars = false) { return $this->lang()->phrase($phrase, $vars); } public function word($word, $quantity = 0, $genre = 'n') { return $this->lang()->word($word, $quantity, $genre); } public function phraseExists($phrase = '') { return $this->lang()->phraseExists($phrase); } private function &lang($lang = false) { try { if ($lang !== false) { if ($this->manifest($lang) === false) $lang = $this->active_lang; } else { $lang = $this->active_lang; } return $this->getInstance($lang, array($this->path)); } catch (\HunterException $e) { \Artise::hunter()->error($e); $empty_object = new \Env\Source\EmptyObject("Lang->$lang()"); return $empty_object; } } public function __construct($plugin = null) { if($plugin === null) self::$instance = &$this; try { if($plugin) $this->path = Artise_Path_Plugins . DS . $plugin . DS . 'langs' . DS; else $this->path = Artise_Path_Langs . DS; $this->instances_class_path = '\Env\xLang\Idiom'; } catch (\HunterException $e) { throw $e; } } private function cs_manifest() { if ($this->manifest === false) { $avoids = array('.', '..', '.svn', '.DS_STORE'); $d = dir($this->path); $this->manifest = array(); while(false !== ($lang = $d->read())) { if(in_array($lang, $avoids)) continue; if(is_file($this->path . $lang) && strlen($lang) > 4) { if (strtolower(substr($lang, -4)) == '.xml') $this->manifest[] = substr($lang, 0, -4); } } $d->close(); } } public function set($lang) { if ($this->active_lang !== false) return false; $this->cs_manifest(); if($this->manifest($lang)) $this->active_lang = $lang; else return false; return true; } public static function &get() { return self::$instance; } } ?>
Return current item: Artise