Browse Source

修正环境变量冲突问题

luolongfei 3 years ago
parent
commit
f83e83964f
6 changed files with 8 additions and 8 deletions
  1. 2 2
      .env.example
  2. 2 2
      app/helpers.php
  3. 1 1
      config.php
  4. 1 1
      libs/Env.php
  5. 1 1
      libs/Lang.php
  6. 1 1
      libs/MessageServices/Mail.php

+ 2 - 2
.env.example

@@ -12,7 +12,7 @@
 #####################################################################
 
 # .env 文件版本
-ENV_FILE_VERSION='v2.4'
+ENV_FILE_VERSION='v2.5'
 
 ######################  账户配置 Account config  #########################
 # Freenom 账户 Freenom Account
@@ -134,7 +134,7 @@ DEBUG=0
 NEW_VERSION_DETECTION=1
 
 # 应用语言配置 Application language configuration, the supported values are zh or en, zh means Chinese, en means English
-LANGUAGE=zh
+CUSTOM_LANGUAGE=zh
 
 # 送信时是否显示服务器信息 1:显示 0:不显示 Whether to display server information when sending messages 1: Display 0: Do not display
 SHOW_SERVER_INFO=0

+ 2 - 2
app/helpers.php

@@ -282,7 +282,7 @@ if (!function_exists('get_local_num')) {
     {
         $num = (string)$num;
 
-        if (\config('language') === 'zh') {
+        if (is_chinese()) {
             return $num;
         }
 
@@ -309,7 +309,7 @@ if (!function_exists('is_chinese')) {
      */
     function is_chinese()
     {
-        return config('language', 'zh') === 'zh';
+        return config('custom_language', 'zh') === 'zh';
     }
 }
 

+ 1 - 1
config.php

@@ -88,7 +88,7 @@ return [
             'name' => lang('100068'),
         ],
     ],
-    'language' => env('LANGUAGE', 'zh'),
+    'custom_language' => env('CUSTOM_LANGUAGE', 'zh'),
     'notice_freq' => (int)env('NOTICE_FREQ', 1), // 通知频率 0:仅当有续期操作的时候 1:每次执行
     'verify_ssl' => (bool)env('VERIFY_SSL', 0), // 请求时验证 SSL 证书行为,默认不验证,防止服务器证书过期或证书颁布者信息不全导致无法发出请求
     'debug' => (bool)env('DEBUG'),

+ 1 - 1
libs/Env.php

@@ -18,7 +18,7 @@ class Env extends Base
      */
     protected $allValues = [];
 
-    public function init($filename = '.env', $overload = true)
+    public function init($filename = '.env', $overload = false)
     {
         if (file_exists(ROOT_PATH . DS . $filename)) {
             $this->setAllValues($filename, $overload);

+ 1 - 1
libs/Lang.php

@@ -19,7 +19,7 @@ class Lang extends Base
     public function init()
     {
         // 读取语言包,语言包位于 resources/lang/ 目录下
-        $this->lang = require sprintf('%s/lang/%s.php', RESOURCES_PATH, strtolower(env('LANGUAGE', 'zh')));
+        $this->lang = require sprintf('%s/lang/%s.php', RESOURCES_PATH, strtolower(env('CUSTOM_LANGUAGE', 'zh')));
     }
 
     /**

+ 1 - 1
libs/MessageServices/Mail.php

@@ -27,7 +27,7 @@ class Mail extends MessageGateway
      */
     public function __construct()
     {
-        $this->language = config('language', 'zh');
+        $this->language = config('custom_language', 'zh');
 
         $this->noticeTemplatePath = sprintf('%s/mail/%s/notice.html', RESOURCES_PATH, $this->language);
         $this->successfulRenewalTemplatePath = sprintf('%s/mail/%s/successful_renewal.html', RESOURCES_PATH, $this->language);