Improving the translatability of project texts

This commit is contained in:
BrettonYe
2024-09-01 22:40:47 +08:00
parent 1603c92d04
commit 7087faf0d6
153 changed files with 8605 additions and 7984 deletions

View File

@@ -7,6 +7,7 @@ use App\Models\Node;
use App\Models\NodeAuth;
use Exception;
use Illuminate\Http\JsonResponse;
use Log;
use Response;
use Str;
@@ -24,34 +25,38 @@ class NodeAuthController extends Controller
$nodes = Node::whereStatus(1)->doesntHave('auth')->orderBy('id')->get();
if ($nodes->isEmpty()) {
return Response::json(['status' => 'success', 'message' => '没有需要生成授权的节点']);
return Response::json(['status' => 'success', 'message' => trans('admin.node.auth.empty')]);
}
$nodes->each(function ($node) {
$node->auth()->create(['key' => Str::random(), 'secret' => Str::random(8)]);
});
return Response::json(['status' => 'success', 'message' => trans('common.generate_item', ['attribute' => trans('common.success')])]);
return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.generate')])]);
}
// 重置节点授权
public function update(NodeAuth $auth): JsonResponse
{
if ($auth->update(['key' => Str::random(), 'secret' => Str::random(8)])) {
return Response::json(['status' => 'success', 'message' => '操作成功']);
return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.reset')])]);
}
return Response::json(['status' => 'fail', 'message' => '操作失败']);
return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.reset')])]);
}
// 删除节点授权
public function destroy(NodeAuth $auth): JsonResponse
{
try {
$auth->delete();
if ($auth->delete()) {
return Response::json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.delete')])]);
}
} catch (Exception $e) {
return Response::json(['status' => 'fail', 'message' => '错误:'.var_export($e, true)]);
Log::error(trans('common.error_action_item', ['action' => trans('common.delete'), 'attribute' => trans('admin.menu.node.auth')]).': '.$e->getMessage());
return Response::json(['status' => 'fail', 'message' => trans('common.error_action_item', ['action' => trans('common.delete'), 'attribute' => trans('admin.menu.node.auth')]).', '.$e->getMessage()]);
}
return Response::json(['status' => 'success', 'message' => '操作成功']);
return Response::json(['status' => 'fail', 'message' => trans('common.failed_item', ['attribute' => trans('common.delete')])]);
}
}