File size: 1.05Kb
<?
class Lang {
static private $data = array();
static private $languageName = 'ru';
static private $languagesList = array('ua', 'ru', 'en');
private function __construct($value) {
if (!in_array($value, self :: $languagesList)) {
$value = self :: $languageName;
} else {
self :: $languageName = $value;
}
$languageFileLocation = H.'system/lang/' . $value . '/Texts.php';
require_once $languageFileLocation;
self :: $data = $lang;
}
public static function setLang($value) {
new self($value);
}
static public function get($value,$var = false) {
if (isset(self :: $data[$value])) {
$repl = array('%s','%s');
$replon = array('%s',$var);
return str_replace($repl,$replon,self :: $data[$value]);
} else {
return 'не переведен';
}
}
static public function getLanguageName() {
return self :: $languageName;
}
}
?>