2017-06-19 17:51:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Lang
|
|
|
|
{
|
|
|
|
private static $_dictionary = null;
|
2019-12-20 17:38:48 +00:00
|
|
|
|
2017-06-19 17:51:59 +00:00
|
|
|
public static function load($lang = 'en'){
|
|
|
|
$lang_file = APP_PATH.'lang/'.$lang.'.ini';
|
|
|
|
if(preg_match('/^[a-z]+$/', $lang) && is_readable($lang_file)){
|
|
|
|
self::$_dictionary = parse_ini_file($lang_file);
|
|
|
|
}
|
|
|
|
}
|
2019-12-20 17:38:48 +00:00
|
|
|
|
2017-06-19 17:51:59 +00:00
|
|
|
public static function get($key){
|
|
|
|
if(!array_key_exists($key, self::$_dictionary)){
|
|
|
|
return $key;
|
|
|
|
}
|
2019-12-20 17:38:48 +00:00
|
|
|
|
2017-06-19 17:51:59 +00:00
|
|
|
return self::$_dictionary[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function __($key){
|
|
|
|
return Lang::get($key);
|
|
|
|
}
|