diff --git a/application/api/controller/Image.php b/application/api/controller/Image.php index 012a9812..838c2d42 100644 --- a/application/api/controller/Image.php +++ b/application/api/controller/Image.php @@ -28,7 +28,7 @@ class Image extends Base { $id = $this->request->post('id'); if (!$image = $this->model->where('id', $id)->find()) { - $this->response('未找到该图片数据', [], 500); + $this->response(lang('The picture data was not found'), [], 500); } $this->response('success', $this->parseData($image)); } @@ -56,9 +56,9 @@ class Image extends Base $data = explode(',', $data); } if ($user->deleteImages($data)) { - $this->response('删除成功!'); + $this->response(lang('Delete succeeded!')); } - $this->response('删除失败!', [], 500); + $this->response(lang('Deletion failed!'), [], 500); } private function parseData($data) diff --git a/application/api/controller/Token.php b/application/api/controller/Token.php index 152e52c9..c38d2c69 100644 --- a/application/api/controller/Token.php +++ b/application/api/controller/Token.php @@ -17,16 +17,16 @@ class Token extends Base $user = null; try { if (!$user = Users::get(['email' => $email])) { - throw new Exception('账号不存在'); + throw new Exception(lang('Account does not exist')); } if ($user->password != md5($password)) { - throw new Exception('账号密码错误'); + throw new Exception(lang('Account password error')); } if ('true' == $refresh) { $token = make_token(); $user->token = $token; if (!$user->save()) { - throw new Exception('Token 刷新失败'); + throw new Exception(lang('Token refresh failed')); } } } catch (Exception $e) { diff --git a/application/api/controller/Upload.php b/application/api/controller/Upload.php index 5f9f0b67..c6404c24 100644 --- a/application/api/controller/Upload.php +++ b/application/api/controller/Upload.php @@ -20,7 +20,7 @@ class Upload extends Base // 是否允许游客上传 if (!$this->getConfig('allowed_tourist_upload') && !request()->user) { - $this->response('管理员关闭了游客上传通道'); + $this->response(lang('The administrator closed the tourist upload channel')); } } diff --git a/application/common/controller/Upload.php b/application/common/controller/Upload.php index e255d2f6..def50b74 100644 --- a/application/common/controller/Upload.php +++ b/application/common/controller/Upload.php @@ -72,7 +72,7 @@ class Upload extends Controller public function exec() { if (!$this->configs['allowed_tourist_upload'] && !$this->user) { - throw new Exception('管理员关闭了游客上传!'); + throw new Exception(lang('The administrator turned off the tourist upload!')); } $sameIpDayMaxUploadCount = $this->getConfig('same_ip_day_max_upload'); @@ -81,7 +81,7 @@ class Upload extends Controller $ipUploadCount = Images::where('ip', '=', request()->ip())->where('create_time', '>=', $startTimestamp) ->count(); if ($ipUploadCount >= $sameIpDayMaxUploadCount) { - throw new Exception('今日图片上传数量已达到上限'); + throw new Exception(lang('The number of pictures uploaded today has reached the maximum')); } } @@ -93,11 +93,11 @@ class Upload extends Controller if ($this->user) { if (($this->user->use_quota + $size) > $this->user->quota) { - throw new Exception('保存失败!您的储存容量不足,请联系管理员!'); + throw new Exception(lang('Save failed! Your storage capacity is insufficient, please contact the administrator!')); } if (!$this->user->state) { - throw new Exception('你的账号被冻结,请联系管理员!'); + throw new Exception(lang('Your account is frozen, please contact the administrator!')); } } @@ -145,7 +145,7 @@ class Upload extends Controller ); break; default: - throw new Exception('自动水印功能配置异常'); + throw new Exception(lang('Abnormal configuration of automatic watermark function')); } $watermark->save($watermarkImage); $temp = $watermarkImage; @@ -166,7 +166,7 @@ class Upload extends Controller if (Config::get('app.app_debug')) { throw new Exception($this->strategy->getError()); } - throw new Exception('上传失败,请检查策略配置是否正确!'); + throw new Exception(lang('Upload failed. Please check whether the policy configuration is correct!')); } isset($watermarkImage) && @unlink($watermarkImage); @@ -185,7 +185,7 @@ class Upload extends Controller // 是否直接拦截色情图片 if (Config::get('system.intercept_salacity')) { $this->strategy->delete($pathname); - throw new Exception('图片[' . $image->getInfo('name') . ']涉嫌违规,禁止上传!'); + throw new Exception(lang('The picture %s is suspected of violation. Uploading is prohibited!', [$image->getInfo('name')])); } $suspicious = 1; } @@ -218,7 +218,7 @@ class Upload extends Controller 'parent_id' => 0, 'name' => $this->user->default_folder ])) { - throw new Exception('文件夹创建失败!'); + throw new Exception(lang('Folder creation failed!')); } } @@ -227,7 +227,7 @@ class Upload extends Controller if (!$model = Images::create($imageData)) { $this->strategy->delete($pathname); - throw new Exception('图片数据保存失败'); + throw new Exception(lang('Failed to save picture data')); } $data = [ @@ -258,7 +258,7 @@ class Upload extends Controller { $image = $this->request->file('image'); if (null === $image) { - throw new Exception('图片资源获取失败'); + throw new Exception(lang('Picture resource acquisition failed')); } if (!is_uploaded_file($image->getPathname())) { throw new Exception('file is not uploaded via HTTP POST'); diff --git a/application/common/model/Users.php b/application/common/model/Users.php index ea7fb04d..3225389d 100644 --- a/application/common/model/Users.php +++ b/application/common/model/Users.php @@ -54,23 +54,23 @@ class Users extends Model public static function login($account, $password, $field = 'email') { if (!$account) { - throw new Exception('请输入账号'); + throw new Exception(lang('Please enter the account number')); } if (!$password) { - throw new Exception('请输入密码'); + throw new Exception(lang('Please input a password')); } if ($user = self::get([$field => $account])) { if (0 === $user->state) { - throw new Exception('你的账户已被冻结,请联系管理员!'); + throw new Exception(lang('Your account has been frozen, please contact the administrator!')); } if ($user->password !== md5($password)) { - throw new Exception('密码不正确'); + throw new Exception(lang('Incorrect password')); } Session::set('uid', $user->id); } else { - throw new Exception('用户不存在'); + throw new Exception(lang('User does not exist')); } } diff --git a/application/common/traits/Core.php b/application/common/traits/Core.php index 7ea8674a..832613b8 100644 --- a/application/common/traits/Core.php +++ b/application/common/traits/Core.php @@ -37,7 +37,7 @@ trait Core { $configs = []; $data = \app\common\model\Config::all(); - foreach ($data as $key => &$value) { + foreach ($data as &$value) { $configs[$value->name] = $value->value; } if ($name) { @@ -63,7 +63,7 @@ trait Core 'msg' => $msg, 'data' => $data ?: new \stdClass(), 'time' => time() - ], $type, 200); + ], $type); throw new HttpResponseException($response); } diff --git a/application/common/validate/Folders.php b/application/common/validate/Folders.php index 3022d99a..e6b46981 100644 --- a/application/common/validate/Folders.php +++ b/application/common/validate/Folders.php @@ -18,11 +18,11 @@ class Folders extends Validate ]; protected $message = [ - 'parent_id.require' => '没有找到上级文件夹', - 'parent_id.number' => '上级文件夹异常', - 'parent_id.integer' => '上级文件夹异常', - 'name.require' => '文件夹名称不能为空', - 'name.max' => '文件夹名称长度最大30个字符', - 'name.chsAlphaNum' => '文件夹名称只能是汉字、字母和数字' + 'parent_id.require' => '{%Parent folder not found}', + 'parent_id.number' => '{%Parent folder exception}', + 'parent_id.integer' => '{%Parent folder exception}', + 'name.require' => '{%Folder name cannot be empty}', + 'name.max' => '{%Folder name length max. 30 characters}', + 'name.chsAlphaNum' => '{%Folder names can only be Chinese characters, letters and numbers}' ]; } diff --git a/application/common/validate/Group.php b/application/common/validate/Group.php index 0712711f..f514d957 100644 --- a/application/common/validate/Group.php +++ b/application/common/validate/Group.php @@ -17,8 +17,8 @@ class Group extends Validate ]; protected $message = [ - 'name.require' => '角色组名称不能为空', - 'name.max' => '角色组名称长度最大30个字符', - 'name.chsAlphaNum' => '角色组名称只能是汉字、字母和数字' + 'name.require' => '{%Role group name cannot be empty}', + 'name.max' => '{%The maximum length of the role group name is 30 characters}', + 'name.chsAlphaNum' => '{%The role group name can only be Chinese characters, letters and numbers}' ]; } diff --git a/application/common/validate/Users.php b/application/common/validate/Users.php index 0c47ae8a..7ed33a69 100644 --- a/application/common/validate/Users.php +++ b/application/common/validate/Users.php @@ -22,20 +22,20 @@ class Users extends Validate ]; protected $message = [ - 'username.require' => '用户名不能为空', - 'username.max' => '用户名字符长度超出', - 'username.unique' => '用户名已存在,请更换', - 'nickname.max' => '昵称字符长度超出', - 'default_folder.max' => '默认上传文件夹名称长度超出', - 'default_folder.chsAlphaNum'=> '默认上传文件夹名称只能是汉字、字母和数字', - 'email.require' => '邮箱不能为空', - 'email.email' => '邮箱格式不正确', - 'email.max' => '邮箱字符长度超出', - 'email.unique' => '邮箱已存在', - 'password.require' => '密码不能为空', - 'password.confirm' => '两次输入的密码不一致', - 'captcha.require' => '请输入验证码', - 'captcha.captcha' => '验证码错误', + 'username.require' => '{%User name cannot be empty}', + 'username.max' => '{%The user name character length exceeds the limit}', + 'username.unique' => '{%User name already exists, please replace}', + 'nickname.max' => '{%The length of nickname characters exceeds the limit}', + 'default_folder.max' => '{%Default upload folder name length exceeds limit}', + 'default_folder.chsAlphaNum'=> '{%The default upload folder name can only be Chinese characters, letters and numbers}', + 'email.require' => '{%Mailbox cannot be empty}', + 'email.email' => '{%The mailbox format is incorrect}', + 'email.max' => '{%Mailbox character length exceeds the limit}', + 'email.unique' => '{%Mailbox already exists}', + 'password.require' => '{%Password cannot be empty}', + 'password.confirm' => '{%The passwords entered twice are inconsistent}', + 'captcha.require' => '{%Please enter the verification code}', + 'captcha.captcha' => '{%Verification code error}', ]; public function sceneEdit() diff --git a/application/http/middleware/ApiAuthenticate.php b/application/http/middleware/ApiAuthenticate.php index d45ad599..d9fc416d 100644 --- a/application/http/middleware/ApiAuthenticate.php +++ b/application/http/middleware/ApiAuthenticate.php @@ -23,19 +23,19 @@ class ApiAuthenticate public function handle(Request $request, \Closure $next) { if (!$this->getConfig('open_api')) { // 站点是否开启了接口 - $this->response('管理员关闭了接口', [], 500); + $this->response(lang('The administrator turned off API functionality'), [], 500); } $user = null; $token = $request->header('token', $request->request('token')); if ($token) { if (!$user = Users::get(['token' => $token])) { - $this->response('认证失败', [], 401); + $this->response(lang('Authentication failed'), [], 401); } } if (!in_array($request->path(), $this->paths)) { - if (!$token) $this->response('Token 不存在', [], 401); + if (!$token) $this->response(lang('Token does not exist'), [], 401); } $request->user = $user; diff --git a/application/index/controller/Auth.php b/application/index/controller/Auth.php index 0897ac15..55f4099b 100644 --- a/application/index/controller/Auth.php +++ b/application/index/controller/Auth.php @@ -33,7 +33,7 @@ class Auth extends Base if ($this->request->isPost()) { try { if ($this->getConfig('close_register')) { - throw new Exception('站点已关闭注册'); + throw new Exception(lang('Site registration closed')); } $data = $this->request->post(); $validate = $this->validate($data, 'Users'); @@ -45,7 +45,7 @@ class Auth extends Base Session::flash('error', $e->getMessage()); return $this->fetch(); } - Session::flash('success', '注册成功'); + Session::flash('success', lang('Registration successful')); $this->redirect(url('auth/login')); } return $this->fetch(); @@ -61,16 +61,16 @@ class Auth extends Base try { $data = $this->request->post(); $validate = $this->validate($data, [ - 'password|密码' => 'require|confirm', + 'password|'.lang('Password') => 'require|confirm', ]); if (true !== $validate) { $this->error($validate); } if ($data['code'] != Session::get('code', 'forgot_')) { - throw new Exception('验证码不正确'); + throw new Exception(lang('Incorrect verification code')); } if (!$user = Users::get(['email' => Session::get('email', 'forgot_')])) { - throw new Exception('用户不存在'); + throw new Exception(lang('User does not exist')); } $user->password = $data['password']; $user->save(); @@ -78,7 +78,7 @@ class Auth extends Base $this->error($e->getMessage()); } $delSession(); - $this->success('重置成功'); + $this->success(lang('Reset successful')); } $delSession(); return $this->fetch(); @@ -89,19 +89,23 @@ class Auth extends Base if ($this->request->isPost()) { $data = $this->request->post(); $validate = $this->validate($data, [ - 'email|邮箱' => 'require|email', - 'captcha|验证码' => 'require|captcha' + 'email|'.lang('Mailbox') => 'require|email', + 'captcha|'.lang('Verification Code') => 'require|captcha' ]); if (true !== $validate) { $this->error($validate); } if (!$user = Users::get(['email' => $data['email']])) { - $this->error('账号不存在'); + $this->error(lang('Account does not exist')); } $code = generate_code(); - $err = $this->sendMail($data['email'], '找回密码', "尊敬的 {$user->username}, 您好,您正在申请重置密码操作,本次的验证码是 {$code},如果不是您本人操作请忽略!"); + $err = $this->sendMail( + $data['email'], + lang('Retrieve password'), + lang('Retrieve password mail content', [$user->username, $code]) + ); if (true !== $err) { $this->error($err); @@ -109,7 +113,7 @@ class Auth extends Base Session::set('code', $code, 'forgot_'); Session::set('email', $data['email'], 'forgot_'); - $this->success('发送成功'); + $this->success(lang('Sent successfully')); } } } diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index eddbbd61..a9e968b1 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -28,7 +28,7 @@ class Index extends Base } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('欢迎回来'); + $this->success(lang('Welcome back')); } return view('index/home'); } @@ -40,7 +40,7 @@ class Index extends Base public function gallery() { if (!$this->getConfig('open_gallery')) { - abort(404, "画廊功能已关闭"); + abort(404, lang('Gallery feature is off')); } $images = []; Images::order('id', 'desc') @@ -62,7 +62,7 @@ class Index extends Base public function api() { if (!$this->getConfig('open_api')) { - abort(404, "API 接口已关闭"); + abort(404, lang('API interface closed')); } $this->assign('domain', $this->request->domain()); return $this->fetch(); diff --git a/application/index/controller/Install.php b/application/index/controller/Install.php index 781eaad2..8f2bd16a 100644 --- a/application/index/controller/Install.php +++ b/application/index/controller/Install.php @@ -19,7 +19,7 @@ class Install extends Controller { // 检测是否已安装 if (file_exists(app()->getAppPath() . 'install.lock') && !Session::has('install_success')) { - exit('你已安装成功,需要重新安装请删除 install.lock 文件'); + exit(lang('Installed tips')); } $phpVerGt56 = PHP_VERSION >= 5.6; @@ -53,7 +53,7 @@ class Install extends Controller try { $installSql = app()->getAppPath() . 'sql/install.sql'; if (!is_file($installSql)) { - throw new Exception('数据库 SQL 文件不存在'); + throw new Exception(lang('The database SQL file does not exist')); } $db = Db::connect(array_merge(\config('database.'), [ 'hostname' => $hostname, @@ -88,7 +88,7 @@ class Install extends Controller } catch (\PDOException $e) { $this->error($e->getMessage()); } - $this->success('数据写入成功'); + $this->success(lang('Data written successfully')); } break; case 3: @@ -102,7 +102,7 @@ class Install extends Controller $data['update_time'] = time(); $data['create_time'] = time(); if ($data['password'] != $data['password_confirm']) { - throw new Exception('两次输入的密码不一致!'); + throw new Exception(lang('The passwords entered twice are inconsistent!')); } $data['password'] = md5($data['password']); $data['reg_ip'] = request()->ip(); @@ -119,7 +119,7 @@ class Install extends Controller '{hostport}', ], $config, @file_get_contents(app()->getRootPath() . '.env.example')); if (!@file_put_contents(app()->getRootPath() . '.env', $env)) { - throw new \Exception('配置文件写入失败'); + throw new \Exception(lang('Configuration file write failed')); } $db = Db::connect(array_merge(\config('database.'), $config)); @@ -128,7 +128,7 @@ class Install extends Controller // 创建安装锁文件 if (!@fopen(app()->getAppPath() . 'install.lock', 'w')) { - throw new \Exception('安装锁文件创建失败'); + throw new \Exception(lang('Setup lock file creation failed')); } } catch (Exception $e) { @unlink(app()->getAppPath() . 'install.lock'); @@ -143,7 +143,7 @@ class Install extends Controller Session::flash('install_success', true); // 删除session Session::delete('db'); - $this->success('设置成功'); + $this->success(lang('Set successfully')); } break; } diff --git a/application/index/controller/Upload.php b/application/index/controller/Upload.php index 5a186b24..2339e72e 100755 --- a/application/index/controller/Upload.php +++ b/application/index/controller/Upload.php @@ -33,6 +33,6 @@ class Upload extends Base return json(['error' => $e->getMessage()]); } - $this->result($data, 200, '上传成功'); + $this->result($data, 200, lang('Upload succeeded')); } } diff --git a/application/index/controller/User.php b/application/index/controller/User.php index 7b767319..fabb5b54 100644 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -71,11 +71,11 @@ class User extends Base foreach ($deletes as $key => $val) { if (1 === count($val)) { if (!$strategy[$key]->delete(isset($val[0]) ? $val[0] : null)) { - // throw new Exception('删除失败'); + // throw new Exception(lang('Deletion failed')); } } else { if (!$strategy[$key]->deletes($val)) { - // throw new Exception('批量删除失败'); + // throw new Exception(lang('Batch deletion failed')); } } } @@ -91,7 +91,7 @@ class User extends Base if ($deleteId) { return true; } - $this->success('删除成功'); + $this->success(lang('Delete succeeded')); } public function createFolder() @@ -113,7 +113,7 @@ class User extends Base } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('创建成功'); + $this->success(lang('Created successfully')); } } @@ -133,7 +133,7 @@ class User extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('删除成功'); + $this->success(lang('Delete succeeded')); } } @@ -151,11 +151,11 @@ class User extends Base $count = $this->user->folders()->where('id', $folderId)->count(); if ($count || $folderId == 0) { if (Images::where('id', 'in', $ids)->setField('folder_id', $folderId)) { - $this->success('移动成功'); + $this->success(lang('Move succeeded')); } - $this->error('移动失败'); + $this->error(lang('Move failed')); } else { - $this->error('该文件夹不存在!'); + $this->error(lang('The folder does not exist!')); } } } @@ -184,7 +184,7 @@ class User extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('重命名成功'); + $this->success(lang('Rename succeeded')); } } @@ -195,17 +195,17 @@ class User extends Base $id = $this->request->post('id'); $name = $this->request->post('name'); - $validate = Validate::make(['name|别名' => 'require|max:60|chsDash']); + $validate = Validate::make(['name|'.lang('Alias') => 'require|max:60|chsDash']); if (!$validate->check(['name' => $name])) { throw new \Exception($validate->getError()); } if (!$this->user->images()->where('id', $id)->update(['alias_name' => $name])) { - throw new \Exception('重命名失败'); + throw new \Exception(lang('Rename failed')); } } catch (\Exception $e) { $this->error($e->getMessage()); } - $this->success('重命名成功'); + $this->success(lang('Rename succeeded')); } } @@ -247,7 +247,7 @@ class User extends Base } if ($data['password_old']) { if (md5($data['password_old']) != $this->user->password) { - throw new Exception('原密码不正确'); + throw new Exception(lang('The original password is incorrect')); } } if (!$data['password']) unset($data['password']); @@ -255,7 +255,7 @@ class User extends Base } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('保存成功'); + $this->success(lang('Saved successfully')); } return $this->fetch(); } diff --git a/application/index/controller/admin/Group.php b/application/index/controller/admin/Group.php index c41d3132..67f7d84c 100644 --- a/application/index/controller/admin/Group.php +++ b/application/index/controller/admin/Group.php @@ -26,7 +26,7 @@ class Group extends Base public function index() { $groups = GroupModel::select()->order('id', 'desc')->each(function ($item) { - $item->strategy_str = isset($this->strategyList[$item->strategy]) ? $this->strategyList[$item->strategy]['name'] : '未知'; + $item->strategy_str = isset($this->strategyList[$item->strategy]) ? $this->strategyList[$item->strategy]['name'] : lang('Unknown'); return $item; }); $this->assign([ @@ -47,13 +47,13 @@ class Group extends Base throw new Exception($validate); } if (!GroupModel::create($data)) { - throw new Exception('添加失败'); + throw new Exception(lang('Add failed')); } } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('添加成功'); + $this->success(lang('Added successfully')); } } @@ -69,16 +69,16 @@ class Group extends Base $data['default'] = array_key_exists('default', $data) ? 1 : 0; if ($data['default'] === 0) { if (!GroupModel::where('default', 1)->where('id', 'neq', $data['id'])->count()) { - throw new Exception('至少保留一个默认分组'); + throw new Exception(lang('Keep at least one default group')); } } if (!GroupModel::update($data)) { - throw new Exception('编辑失败'); + throw new Exception(lang('Edit failed')); } } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('编辑成功'); + $this->success(lang('Edit succeeded')); } } @@ -89,13 +89,13 @@ class Group extends Base try { $id = $this->request->post('id'); if (1 == $id) { - throw new Exception('默认组不可删除'); + throw new Exception(lang('The default group cannot be deleted')); } $group = GroupModel::find($id); // 至少保留一个默认分组 $defaultId = GroupModel::where('default', 1)->where('id', 'neq', $id)->value('id'); if (!$defaultId) { - throw new Exception('至少保留一个默认分组'); + throw new Exception(lang('Keep at least one default group')); } // 转移该组下的用户到默认分组 \app\common\model\Users::where('group_id', $group->id)->setField('group_id', $defaultId); @@ -105,7 +105,7 @@ class Group extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('删除成功'); + $this->success(lang('Delete succeeded')); } } @@ -124,16 +124,16 @@ class Group extends Base $value = $this->request->post('value'); if (1 != $value) { if (!GroupModel::where('default', 1)->where('id', 'neq', $id)->count()) { - $this->error('至少保留一个默认分组'); + $this->error(lang('Keep at least one default group')); } } if (!GroupModel::update([ 'id' => $id, 'default' => $value ])) { - $this->error('设置失败'); + $this->error(lang('Setting failed')); } - $this->success('设置成功'); + $this->success(lang('Setting succeeded')); } } @@ -143,15 +143,15 @@ class Group extends Base $id = $this->request->post('id'); $strategy = $this->request->post('strategy'); if (!array_key_exists($strategy, $this->strategyList)) { - $this->error('储存策略不存在'); + $this->error(lang('Storage policy does not exist')); } if (!GroupModel::update([ 'id' => $id, 'strategy' => $strategy ])) { - $this->error('设置失败'); + $this->error(lang('Setting failed')); } - $this->success('设置成功'); + $this->success(lang('Setting succeeded')); } } } diff --git a/application/index/controller/admin/Images.php b/application/index/controller/admin/Images.php index dd77ad2c..ea8f8336 100644 --- a/application/index/controller/admin/Images.php +++ b/application/index/controller/admin/Images.php @@ -53,8 +53,8 @@ class Images extends Base ] ])->each(function ($item) { $username = Users::where('id', $item->user_id)->value('username'); - $item->username = $username ? $username : '访客'; - $item->strategyStr = isset($this->strategyList[$item->strategy]) ? $this->strategyList[$item->strategy]['name'] : '未知'; + $item->username = $username ? $username : lang('Visitor'); + $item->strategyStr = isset($this->strategyList[$item->strategy]) ? $this->strategyList[$item->strategy]['name'] : lang('Unknown'); return $item; }); $this->assign([ @@ -98,11 +98,11 @@ class Images extends Base foreach ($deletes as $key => $val) { if (1 === count($val)) { if (!$strategy[$key]->delete(isset($val[0]) ? $val[0] : null)) { - // throw new Exception('删除失败'); + // throw new Exception(lang('Deletion failed')); } } else { if (!$strategy[$key]->deletes($val)) { - // throw new Exception('批量删除失败'); + // throw new Exception(lang('Batch deletion failed')); } } } @@ -112,7 +112,7 @@ class Images extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('删除成功'); + $this->success(lang('Delete succeeded')); } } @@ -145,11 +145,11 @@ class Images extends Base } } } catch (Exception $e) { - $this->error('获取失败'); + $this->error(lang('Acquisition failed')); } catch (RequestException $e) { - $this->error('接口发生异常,' . $e->getMessage()); + $this->error(lang('The interface is abnormal, %s', [$e->getMessage()])); } - $this->success('获取成功', null, $data); + $this->success(lang('Get success'), null, $data); } } } diff --git a/application/index/controller/admin/Strategy.php b/application/index/controller/admin/Strategy.php index 5f23709a..7a2d1b7e 100644 --- a/application/index/controller/admin/Strategy.php +++ b/application/index/controller/admin/Strategy.php @@ -44,7 +44,7 @@ class Strategy extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('保存成功'); + $this->success(lang('Saved successfully')); } return $this->fetch(); } diff --git a/application/index/controller/admin/System.php b/application/index/controller/admin/System.php index 2a979a4b..249fbb8b 100644 --- a/application/index/controller/admin/System.php +++ b/application/index/controller/admin/System.php @@ -41,7 +41,7 @@ class System extends Base Db::rollback(); $this->error($e->getMessage()); } - $this->success('保存成功'); + $this->success(lang('Saved successfully')); } // 命名规则 $naming = \think\facade\Config::pull('naming'); @@ -78,11 +78,11 @@ class System extends Base { if ($this->request->isPost()) { $email = $this->request->post('email'); - $err = $this->sendMail($email, '测试', '这是一封测试邮件!'); + $err = $this->sendMail($email, lang('Test'), lang('This is a test email!')); if (true !== $err) { $this->error($err); } - $this->success('发送成功'); + $this->success(lang('Sent successfully')); } } @@ -94,7 +94,7 @@ class System extends Base $upgrade = null; try { if (!class_exists('ZipArchive')) { - throw new \Exception('无法继续执行, 请确保 ZipArchive 正确安装'); + throw new \Exception(lang('Cannot continue, please make sure ZipArrive is installed correctly')); } ignore_user_abort(true); @@ -106,33 +106,33 @@ class System extends Base $release = $upgrade->release(); // 获取最新版 // 判断是否已经是最新版 if ($upgrade->check($release->version)) { - throw new \Exception('当前系统已经是最新版'); + throw new \Exception(lang('The current system is the latest version')); } $upgradeFile = app()->getRuntimePath() . 'upgrade.zip';// 判断是否存在安装包 $file = file_exists($upgradeFile) ? $upgradeFile : $upgrade->download($release->url); // 校验 MD5 if (strtolower(md5_file($file)) !== strtolower($release->md5)) { - throw new \Exception('安装包损坏, 请稍后重试'); + throw new \Exception(lang('The installation package is corrupt. Please try again later')); } $dir = $upgrade->unzip($file, $upgrade->getWorkspace()); // 解压安装包到工作区目录 $path = rtrim($dir . strtolower($release->path), '/') . '/'; // 新版本程序解压后的根目录 $updateSql = $path . $release->sql; // 更新数据库结构 sql 文件路径 if (!$sql = @file_get_contents($updateSql)) { - throw new \Exception('SQL 文件获取失败'); + throw new \Exception(lang('SQL file acquisition failed')); } // 创建安装锁文件 if (!@fopen($path . 'application/install.lock', 'w')) { - throw new \Exception('安装锁文件创建失败'); + throw new \Exception(lang('Setup lock file creation failed')); } Db::startTrans(); // 检测新增表字段 if (!$tableFields = @include($path . 'config/table.php')) { - throw new \Exception('表字段配置文件获取失败'); + throw new \Exception(lang('Failed to get table field configuration file')); } foreach ($tableFields as $table => $fields) { foreach ($fields as $field => $sql) { @@ -191,7 +191,7 @@ class System extends Base @$upgrade->rmdir($upgrade->getWorkspace()); $this->error($e->getMessage()); } - $this->success('升级完成'); + $this->success(lang('Upgrade Complete')); } /** @@ -212,6 +212,6 @@ class System extends Base } catch (\Throwable $e) { $this->error($e->getMessage()); } - $this->success('备份完成, ' . $backup); + $this->success(lang('Backup complete, %s', [$backup])); } } diff --git a/application/index/controller/admin/Users.php b/application/index/controller/admin/Users.php index 45de134d..d637b7b0 100644 --- a/application/index/controller/admin/Users.php +++ b/application/index/controller/admin/Users.php @@ -49,17 +49,17 @@ class Users extends Base $id = $this->request->post('id'); if (is_array($id)) { if (in_array($this->user->id, $id)) { - $this->error('不能删除自己的账号!'); + $this->error(lang('You cannot delete your account!')); } } else { if ($id == $this->user->id) { - $this->error('不能删除自己的账号!'); + $this->error(lang('You cannot delete your account!')); } } if (!UsersModel::destroy($id)) { - $this->error('删除失败'); + $this->error(lang('Deletion failed')); } - $this->success('删除成功'); + $this->success(lang('Delete succeeded')); } } @@ -69,18 +69,18 @@ class Users extends Base $id = $this->request->post('id'); if (is_array($id)) { if (in_array($this->user->id, $id)) { - $this->error('不能冻结自己的账号!'); + $this->error(lang('You can\'t freeze your account!')); } } else { if ($id == $this->user->id) { - $this->error('不能冻结自己的账号!'); + $this->error(lang('You can\'t freeze your account!')); } } $model = new UsersModel(); if (!$model->where('id', 'in', $id)->update(['state' => 0])) { - $this->error('冻结失败'); + $this->error(lang('Freeze failed')); } - $this->success('冻结成功'); + $this->success(lang('Freeze succeeded')); } } @@ -89,10 +89,10 @@ class Users extends Base if ($this->request->isPost()) { $id = $this->request->post('id'); if (!$user = UsersModel::get($id)) { - $this->error('数据获取失败'); + $this->error(lang('Data acquisition failed')); } unset($user->password); - $this->success('成功', null, $user); + $this->success(lang('Success'), null, $user); } } @@ -107,12 +107,12 @@ class Users extends Base } if (!$data['password']) unset($data['password'], $data['password_confirm']); if (!UsersModel::update($data)) { - throw new Exception('修改失败'); + throw new Exception(lang('Modification failed')); } } catch (Exception $e) { $this->error($e->getMessage()); } - $this->success('保存成功'); + $this->success(lang('Saved successfully')); } } @@ -122,15 +122,15 @@ class Users extends Base $id = $this->request->post('id'); $state = $this->request->post('state'); if (!$user = UsersModel::get($id)) { - $this->error('数据获取失败'); + $this->error(lang('Data acquisition failed')); } if ($user->id === $this->user->id) { - $this->error('不可修改自己的状态'); + $this->error(lang('You cannot modify your status')); } if (!$user->where('id', $id)->setField('state', $state)) { - $this->error('状态修改失败'); + $this->error(lang('Status modification failed')); } - $this->success('状态修改成功'); + $this->success(lang('Status modification succeeded')); } } @@ -140,12 +140,12 @@ class Users extends Base $id = $this->request->post('id'); $groupId = $this->request->post('group_id'); if (!$group = \app\common\model\Group::find($groupId)) { - $this->error('数据获取失败'); + $this->error('Data acquisition failed'); } if (!UsersModel::where('id', $id)->setField('group_id', $groupId)) { - $this->error('修改失败'); + $this->error(lang('Modification failed')); } - $this->success('修改成功'); + $this->success(lang('Modified successfully')); } } } diff --git a/application/index/view/admin/group/index.html b/application/index/view/admin/group/index.html index 43c283c8..20f9dfd8 100644 --- a/application/index/view/admin/group/index.html +++ b/application/index/view/admin/group/index.html @@ -29,7 +29,7 @@ @@ -65,7 +65,7 @@ @@ -95,7 +95,7 @@ diff --git a/application/index/view/admin/images/index.html b/application/index/view/admin/images/index.html index be4adea5..1ec22fda 100644 --- a/application/index/view/admin/images/index.html +++ b/application/index/view/admin/images/index.html @@ -12,7 +12,7 @@
{:lang('There are %s pictures in total', [''.$images->total().''])} - +
diff --git a/application/index/view/admin/strategy/index.html b/application/index/view/admin/strategy/index.html index 101f785d..c0f7294d 100644 --- a/application/index/view/admin/strategy/index.html +++ b/application/index/view/admin/strategy/index.html @@ -22,10 +22,10 @@ {foreach $value as $val}
- + {switch $val.type} {case text} - + {/case} {case bool}
diff --git a/application/index/view/admin/system/index.html b/application/index/view/admin/system/index.html index 38a65c7b..378cbe59 100644 --- a/application/index/view/admin/system/index.html +++ b/application/index/view/admin/system/index.html @@ -78,8 +78,8 @@ {foreach $naming.path as $value} {$value.name} - {$value.example} - {$value.explain} + {:lang($value.example)} + {:lang($value.explain)} {/foreach} @@ -102,8 +102,8 @@ {foreach $naming.file as $value} {$value.name} - {$value.example} - {$value.explain} + {:lang($value.example)} + {:lang($value.explain)} {/foreach} @@ -127,7 +127,7 @@ }); $('#test-send-mail').click(function () { - mdui.prompt(lang('Please input email'), + mdui.prompt(lang('Please input mailbox'), function (value) { app.request("{:url('admin/system/testMail')}", {email: value}); }, diff --git a/application/index/view/admin/users/index.html b/application/index/view/admin/users/index.html index b26c6949..4778998c 100644 --- a/application/index/view/admin/users/index.html +++ b/application/index/view/admin/users/index.html @@ -28,7 +28,7 @@ {:lang('User name')} {:lang('Role group')} {:lang('Nickname')} - {:lang('Email')} + {:lang('Mailbox')} {:lang('Used capacity')} {:lang('Total capacity')} {:lang('Account status')} @@ -43,7 +43,7 @@ @@ -82,8 +82,8 @@
- - + +
diff --git a/application/index/view/auth/forgot.html b/application/index/view/auth/forgot.html index d3cd1222..9bff17ba 100644 --- a/application/index/view/auth/forgot.html +++ b/application/index/view/auth/forgot.html @@ -1,6 +1,6 @@ {extend name="common:base" /} -{block name="title"}找回密码 - {$config.site_name}{/block} +{block name="title"}{:lang('Retrieve password')} - {$config.site_name}{/block} {block name="main"}
@@ -8,37 +8,37 @@
-
找回密码
+
{:lang('Retrieve password')}
- +
- + - 验证码 + {:lang('Verification Code')}
- +
- +
- +
- +
- +
@@ -69,4 +69,4 @@ }); }); -{/block} \ No newline at end of file +{/block} diff --git a/application/index/view/auth/login.html b/application/index/view/auth/login.html index a0871277..2bd89b20 100644 --- a/application/index/view/auth/login.html +++ b/application/index/view/auth/login.html @@ -1,6 +1,6 @@ {extend name="common:base" /} -{block name="title"}登录 - {$config.site_name}{/block} +{block name="title"}{:lang('Sign In')} - {$config.site_name}{/block} {block name="css"} @@ -12,33 +12,33 @@