소스 검색

默认用英语

lizhen_gitee 2 달 전
부모
커밋
6092261996
1개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 3
      application/common/controller/Api.php

+ 6 - 3
application/common/controller/Api.php

@@ -66,7 +66,7 @@ class Api
      */
     protected $responseType = 'json';
 
-    protected $lang = 'CN';
+    protected $lang = 'en';
 
     /**
      * @var int 日志类型 1 文件;2sql
@@ -81,7 +81,10 @@ class Api
     public function __construct(Request $request = null)
     {
         $this->request = is_null($request) ? Request::instance() : $request;
-        $this->lang = $this->request->header('lang','CN');
+        $this->lang = $this->request->header('lang','en');
+        if(!in_array($this->lang,['en','zh-cn'])){
+            $this->lang = 'en';
+        }
 
         // 控制器初始化
         $this->_initialize();
@@ -168,7 +171,7 @@ class Api
         $name = preg_match("/^([a-zA-Z0-9_\.\/]+)\$/i", $name) ? $name : 'index';
         //$lang = $this->request->langset();
         $lang = $this->lang;
-        $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
+        $lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'en';
         Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
     }