From 2e0ee6811c02722efd261615b199bb35ed9b5e05 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Thu, 11 May 2023 09:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/default/admin/login_info.html | 2 +- app/api/controller/Devtest.php | 109 ++++++++++++++++++ app/common.php | 2 +- app/index/lang/cht.php | 4 + app/index/lang/de.php | 4 + app/index/lang/en.php | 4 + app/index/lang/fra.php | 4 + app/index/lang/it.php | 4 + app/index/lang/jp.php | 4 + app/index/lang/kor.php | 4 + app/index/lang/nl.php | 4 + app/index/lang/ru.php | 4 + app/index/lang/spa.php | 4 + app/index/lang/swe.php | 4 + app/index/lang/th.php | 4 + app/index/lang/vie.php | 4 + app/index/lang/zh.php | 4 + .../view/default/public/footer_filing.html | 8 +- public/core.php | 2 +- 19 files changed, 172 insertions(+), 7 deletions(-) diff --git a/app/admin/view/default/admin/login_info.html b/app/admin/view/default/admin/login_info.html index 0d41dca3c..a0210c2aa 100755 --- a/app/admin/view/default/admin/login_info.html +++ b/app/admin/view/default/admin/login_info.html @@ -125,7 +125,7 @@ {{else /}}
- {{:MyLang('user.login_close_tips')}} + {{:MyLang('admin.login_close_tips')}}
{{/if}} diff --git a/app/api/controller/Devtest.php b/app/api/controller/Devtest.php index d64328292..2d389df40 100644 --- a/app/api/controller/Devtest.php +++ b/app/api/controller/Devtest.php @@ -615,6 +615,115 @@ class Devtest extends Common } die('success:'.$success.', fail:'.$fail); } + /** + * 插件语言翻译生成 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2023-03-24 + * @desc description + */ + public function PluginsFanyi() + { + // if(input('pwd') != 'shopxo520') + // { + // die('非法访问'); + // } + // die('禁止访问'); + + // 需要翻译的语言、参考 config/lang.php文件 + $to = 'en'; + $to_name = '英文'; + $plugins = 'erp'; + + // 待翻译的目录 + $arr = [ + APP_PATH.'plugins'.DS.$plugins.DS.'lang'.DS, + APP_PATH.'plugins'.DS.$plugins.DS.'lang'.DS.'admin'.DS, + APP_PATH.'plugins'.DS.$plugins.DS.'lang'.DS.'index'.DS, + ]; + + // 获取数据 + $zh_data = []; + foreach($arr as $dir) + { + if(!is_dir($dir)) + { + continue; + } + $zh_file = $dir.'zh.php'; + if(!file_exists($zh_file)) + { + continue; + } + $temp = require $zh_file; + $zh_data = array_merge($zh_data, $this->FanyiData($temp)); + } + + // 翻译数据 并 生成数据 + $params = []; + $vers = get_class_vars(get_class()); + foreach($vers as $k=>$v) + { + if(property_exists($this, $k)) + { + $params[$k] = $this->$k; + } + } + $params['data_request']['to'] = $to; + $params['data_request']['q'] = implode("\n", $zh_data); + //$params['data_request']['q'] = "你好\n我是龚"; + $fanyi = PluginsControlCall('multilingual', 'index', 'fanyi', 'index', $params, 1); + if(isset($fanyi['code']) && $fanyi['code'] != 0) + { + die($fanyi['msg']); + } + $fanyi_data = (!empty($fanyi['data']) && !empty($fanyi['data']['trans_result'])) ? $fanyi['data']['trans_result'] : []; + if(empty($fanyi_data)) + { + die('没有翻译数据'); + } + + // 替换数据 + $search = array_map(function($item) + { + return "'".$item."'"; + }, array_column($fanyi_data, 'src')); + $replace = array_map(function($item) + { + return "'".str_replace("'", '', $item)."'"; + }, array_column($fanyi_data, 'dst')); + // 加入标题名称 + $search[] = '语言包-中文'; + $replace[] = '语言包-'.$to_name; + + // 开始生成文件并替换数据 + $success = 0; + $fail = 0; + foreach($arr as $dir) + { + // 复制文件 + $zh_file = $dir.'zh.php'; + if(!file_exists($zh_file)) + { + continue; + } + $to_file = $dir.$to.'.php'; + if(!\base\FileUtil::CopyFile($zh_file, $to_file, true)) + { + continue; + } + // 生成文件并替换 + $content = file_get_contents($to_file); + if(file_put_contents($to_file, str_replace($search, $replace, $content)) !== false) + { + $success++; + } else { + $fail++; + } + } + die('success:'.$success.', fail:'.$fail); + } // 翻译数据递归获取 public function FanyiData($data) { diff --git a/app/common.php b/app/common.php index f6296466d..d1ba08284 100755 --- a/app/common.php +++ b/app/common.php @@ -714,7 +714,7 @@ function GetUrlHost($url) } // 判断是否是双后缀 - $preg = '/[\w].+\.(com|net|org|gov|ac|bj|sh|tj|cq|he|sn|sx|nm|ln|jl|hl|js|zj|ah|fj|jx|sd|ha|hb|hn|gd|gx|hi|sc|gz|yn|gs|qh|nx|xj|tw|hk|mo|xz|edu|ge|dev|co)\.(cn|nz|mm)$/'; + $preg = '/[\w].+\.(com|net|org|gov|ac|bj|sh|tj|cq|he|sn|sx|nm|ln|jl|hl|js|zj|ah|fj|jx|sd|ha|hb|hn|gd|gx|hi|sc|gz|yn|gs|qh|nx|xj|tw|hk|mo|xz|edu|ge|dev|co)\.(cn|nz|mm|ec)$/'; if(($n > 2) && preg_match($preg, $host)) { // 双后缀取后3位 diff --git a/app/index/lang/cht.php b/app/index/lang/cht.php index f915f0eca..825532de5 100644 --- a/app/index/lang/cht.php +++ b/app/index/lang/cht.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => '暫時關閉用戶註冊', 'close_user_login_tips' => '暫時關閉用戶登錄', + // 底部 + 'footer_icp_filing_text' => 'ICP備案', + 'footer_public_security_filing_text' => '警察備案', + 'footer_business_license_text' => '電子營業執照亮照', ], // 首页 diff --git a/app/index/lang/de.php b/app/index/lang/de.php index 65abac383..43b5478cf 100644 --- a/app/index/lang/de.php +++ b/app/index/lang/de.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Benutzerregistrierung vorübergehend schließen', 'close_user_login_tips' => 'Benutzeranmeldung vorübergehend deaktivieren', + // 底部 + 'footer_icp_filing_text' => 'ICP-Einreichung', + 'footer_public_security_filing_text' => 'Einreichung der öffentlichen Sicherheit', + 'footer_business_license_text' => 'Elektronische Gewerbelizenzbeleuchtung', ], // 首页 diff --git a/app/index/lang/en.php b/app/index/lang/en.php index c41222524..702adbb53 100644 --- a/app/index/lang/en.php +++ b/app/index/lang/en.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Temporarily close user registration', 'close_user_login_tips' => 'Temporarily close user login', + // 底部 + 'footer_icp_filing_text' => 'ICP Filing', + 'footer_public_security_filing_text' => 'Public Security Filing', + 'footer_business_license_text' => 'Electronic Business License Illumination', ], // 首页 diff --git a/app/index/lang/fra.php b/app/index/lang/fra.php index a55a6f391..c5f317685 100644 --- a/app/index/lang/fra.php +++ b/app/index/lang/fra.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Fermer temporairement linscription des utilisateurs', 'close_user_login_tips' => 'Fermer temporairement le login de lutilisateur', + // 底部 + 'footer_icp_filing_text' => 'Dépôt ICP', + 'footer_public_security_filing_text' => 'Dépôt de la sécurité publique', + 'footer_business_license_text' => 'Licence dentreprise électronique illuminée', ], // 首页 diff --git a/app/index/lang/it.php b/app/index/lang/it.php index 2886f2362..b056ed34d 100644 --- a/app/index/lang/it.php +++ b/app/index/lang/it.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Registrazione temporanea dellutente', 'close_user_login_tips' => 'Disattivare temporaneamente laccesso utente', + // 底部 + 'footer_icp_filing_text' => 'Deposito ICP', + 'footer_public_security_filing_text' => 'Archiviazione di pubblica sicurezza', + 'footer_business_license_text' => 'Illuminazione elettronica delle licenze commerciali', ], // 首页 diff --git a/app/index/lang/jp.php b/app/index/lang/jp.php index 3f3d88c53..726b6d60b 100644 --- a/app/index/lang/jp.php +++ b/app/index/lang/jp.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'ユーザー登録の一時停止', 'close_user_login_tips' => 'ユーザーログインの一時停止', + // 底部 + 'footer_icp_filing_text' => 'ICP届出', + 'footer_public_security_filing_text' => '警察の届出', + 'footer_business_license_text' => '電子営業許可証点灯', ], // 首页 diff --git a/app/index/lang/kor.php b/app/index/lang/kor.php index a2065111e..9805c5e24 100644 --- a/app/index/lang/kor.php +++ b/app/index/lang/kor.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => '사용자 등록 일시 해제', 'close_user_login_tips' => '사용자 로그인 일시 닫기', + // 底部 + 'footer_icp_filing_text' => 'ICP 등록', + 'footer_public_security_filing_text' => '공안 등록', + 'footer_business_license_text' => '전자 영업 허가증', ], // 首页 diff --git a/app/index/lang/nl.php b/app/index/lang/nl.php index 8dc731eeb..5f4769bf4 100644 --- a/app/index/lang/nl.php +++ b/app/index/lang/nl.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Gebruikersregistratie tijdelijk afsluiten', 'close_user_login_tips' => 'Gebruikersaanmelding tijdelijk uitschakelen', + // 底部 + 'footer_icp_filing_text' => 'ICP-indiening', + 'footer_public_security_filing_text' => 'Openbare veiligheid', + 'footer_business_license_text' => 'Verlichting van elektronische bedrijfsvergunning', ], // 首页 diff --git a/app/index/lang/ru.php b/app/index/lang/ru.php index daebb71cf..8b50cde87 100644 --- a/app/index/lang/ru.php +++ b/app/index/lang/ru.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Временное закрытие регистрации пользователей', 'close_user_login_tips' => 'Временно отключить вход пользователя', + // 底部 + 'footer_icp_filing_text' => 'Регистрация ICP', + 'footer_public_security_filing_text' => 'Регистрация общественной безопасности', + 'footer_business_license_text' => 'Электронная лицензия.', ], // 首页 diff --git a/app/index/lang/spa.php b/app/index/lang/spa.php index d4698d21a..730626a3a 100644 --- a/app/index/lang/spa.php +++ b/app/index/lang/spa.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Cierre temporal del registro de usuarios', 'close_user_login_tips' => 'Cierre temporalmente el inicio de sesión del usuario', + // 底部 + 'footer_icp_filing_text' => 'Registro ICP', + 'footer_public_security_filing_text' => 'Registro de seguridad pública', + 'footer_business_license_text' => 'Licencia comercial electrónica iluminada', ], // 首页 diff --git a/app/index/lang/swe.php b/app/index/lang/swe.php index 1e4e6515e..b8e2552de 100644 --- a/app/index/lang/swe.php +++ b/app/index/lang/swe.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Tillfälligt stängd användarregistrering', 'close_user_login_tips' => 'Stäng tillfälligt av användarinloggning', + // 底部 + 'footer_icp_filing_text' => 'ICP-arkivering', + 'footer_public_security_filing_text' => 'Registrering av allmän säkerhet', + 'footer_business_license_text' => 'Elektronisk affärslicensbelysning', ], // 首页 diff --git a/app/index/lang/th.php b/app/index/lang/th.php index 064742403..1cb700d4a 100644 --- a/app/index/lang/th.php +++ b/app/index/lang/th.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'ปิดการลงทะเบียนผู้ใช้ชั่วคราว', 'close_user_login_tips' => 'ปิดการเข้าสู่ระบบผู้ใช้ชั่วคราว', + // 底部 + 'footer_icp_filing_text' => 'การยื่น ICP', + 'footer_public_security_filing_text' => 'บันทึกความปลอดภัยสาธารณะ', + 'footer_business_license_text' => 'ใบอนุญาตประกอบธุรกิจอิเล็กทรอนิกส์', ], // 首页 diff --git a/app/index/lang/vie.php b/app/index/lang/vie.php index 547dde0ba..80ba05d4c 100644 --- a/app/index/lang/vie.php +++ b/app/index/lang/vie.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => 'Tạm thời đóng đăng ký người dùng', 'close_user_login_tips' => 'Tạm thời tắt đăng nhập người dùng', + // 底部 + 'footer_icp_filing_text' => 'Hồ sơ ICP', + 'footer_public_security_filing_text' => 'Công an lập hồ sơ', + 'footer_business_license_text' => 'Giấy phép kinh doanh điện tử', ], // 首页 diff --git a/app/index/lang/zh.php b/app/index/lang/zh.php index 6f0430520..10987afc7 100755 --- a/app/index/lang/zh.php +++ b/app/index/lang/zh.php @@ -51,6 +51,10 @@ return [ ], 'close_user_register_tips' => '暂时关闭用户注册', 'close_user_login_tips' => '暂时关闭用户登录', + // 底部 + 'footer_icp_filing_text' => 'ICP备案', + 'footer_public_security_filing_text' => '公安备案', + 'footer_business_license_text' => '电子营业执照亮照', ], // 首页 diff --git a/app/index/view/default/public/footer_filing.html b/app/index/view/default/public/footer_filing.html index 0908c6feb..7408a584c 100644 --- a/app/index/view/default/public/footer_filing.html +++ b/app/index/view/default/public/footer_filing.html @@ -5,7 +5,7 @@ | @@ -14,7 +14,7 @@ | @@ -23,8 +23,8 @@ | {{/if}} diff --git a/public/core.php b/public/core.php index a2493a2e0..737e92df9 100755 --- a/public/core.php +++ b/public/core.php @@ -66,7 +66,7 @@ if(empty($_SERVER['HTTP_HOST'])) $main_domain = ''; } else { // 判断是否是双后缀 - $preg = '/[\w].+\.(com|net|org|gov|ac|bj|sh|tj|cq|he|sn|sx|nm|ln|jl|hl|js|zj|ah|fj|jx|sd|ha|hb|hn|gd|gx|hi|sc|gz|yn|gs|qh|nx|xj|tw|hk|mo|xz|edu|ge|dev|co)\.(cn|nz|mm)$/'; + $preg = '/[\w].+\.(com|net|org|gov|ac|bj|sh|tj|cq|he|sn|sx|nm|ln|jl|hl|js|zj|ah|fj|jx|sd|ha|hb|hn|gd|gx|hi|sc|gz|yn|gs|qh|nx|xj|tw|hk|mo|xz|edu|ge|dev|co)\.(cn|nz|mm|ec)$/'; if($len > 2 && preg_match($preg, $main_domain)) { // 双后缀取后3位