think\Lang::set PHP Method

set() public static method

设置语言定义(不区分大小写)
public static set ( string | array $name, string $value = null, string $range = '' ) : mixed
$name string | array 语言变量
$value string 语言值
$range string 语言作用域
return mixed
    public static function set($name, $value = null, $range = '')
    {
        $range = $range ?: self::$range;
        // 批量定义
        if (!isset(self::$lang[$range])) {
            self::$lang[$range] = [];
        }
        if (is_array($name)) {
            return self::$lang[$range] = array_change_key_case($name) + self::$lang[$range];
        } else {
            return self::$lang[$range][strtolower($name)] = $value;
        }
    }

Usage Example

Example #1
0
 public function testRange()
 {
     $this->assertEquals('zh-cn', Lang::range());
     Lang::set('hello', '欢迎', 'test');
     Lang::range('test');
     $this->assertEquals('test', Lang::range());
     $this->assertEquals('欢迎', Lang::get('hello'));
 }
All Usage Examples Of think\Lang::set