改进Config类和App类 Lange类

支持扩展配置文件分离
This commit is contained in:
thinkphp
2015-12-01 19:47:57 +08:00
parent 2375e257b3
commit 5f1fe79e17
11 changed files with 145 additions and 116 deletions

View File

@@ -14,11 +14,11 @@ namespace think;
class Lang
{
// 语言参数
private static $lang = [];
// 作用域
private static $range = '_sys_';
private static $lang = [];
// 语言作用域
private static $range = '';
// 设定语言参数的作用域
// 设定语言参数的作用域(语言)
public static function range($range)
{
self::$range = $range;
@@ -42,6 +42,20 @@ class Lang
}
}
/**
* 加载语言定义(不区分大小写)
* @param string $file 语言文件
* @param string $range 作用域
* @return mixed
*/
public static function load($file, $range = '')
{
$range = $range ? $range : self::$range;
$lang = is_file($file) ? include $file : [];
// 批量定义
return self::$lang[$range] = array_merge(self::$lang[$range], array_change_key_case($lang));
}
/**
* 获取语言定义(不区分大小写)
* @param string|null $name 语言变量