tp6加载多语言包

587 阅读1分钟

像fastadmin一样,把文件放在对应的

use think\facade\Request;
use think\facade\Cookie;
use think\facade\Lang;
 		$this->request =Request::instance();  
 	//模块
        $module=app('http')->getName();
       //控制器下
        $controllername= $this->request->controller();  
        //加载语言包
        Lang::load(root_path() .'/app/' .  $module. '/lang/' .Lang::getLangSet() . '/' . str_replace('.', '/', $controllername) . '.php');
        //解析语言
        var_dump(__("Keep login"));die;