lizhen_gitee 2 hónapja
szülő
commit
6092261996
1 módosított fájl, 6 hozzáadás és 3 törlés
  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');
     }