Файл: wboard/source/system/classes/language.php
Строк: 34
<?php
/**
* Wboard
* Languages handler
* @author Screamer
* @copyright 2013
*/
class Language
{
/**
* @var (array) Storage for language
*/
protected $_storage = array();
/**
* Constructor
* Load language file and set data to storage
* @throws (Exception) Wrong format of file or file is not extists
* @return (void)
*/
public function __construct($file)
{
if (is_file($file)) {
$data = require $file;
if (!is_array($data)) {
throw new Exception(__CLASS__ . ': wrong format of language file ' . $file);
} else {
$this->_storage = array_merge($data, $this->_storage);
}
} else {
throw new Exception(__CLASS__ . ': file ' . $file . ' is not exists');
}
}
/**
* Get language item
* @param (string) $name Name of item
* @return (string)
*/
public function __get($name)
{
return isset($this->_storage[$name]) ? $this->_storage[$name] : '#' . $name . '#';
}
}