mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
no message
This commit is contained in:
parent
a393dec0a0
commit
50a7950ccd
@ -13,6 +13,9 @@ class CreateWebSocketDialogMsgTranslatesTable extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
if (Schema::hasTable('web_socket_dialog_msg_translates'))
|
||||||
|
return;
|
||||||
|
|
||||||
Schema::create('web_socket_dialog_msg_translates', function (Blueprint $table) {
|
Schema::create('web_socket_dialog_msg_translates', function (Blueprint $table) {
|
||||||
$table->bigIncrements('id');
|
$table->bigIncrements('id');
|
||||||
$table->bigInteger('dialog_id')->nullable()->default(0)->comment('对话ID');
|
$table->bigInteger('dialog_id')->nullable()->default(0)->comment('对话ID');
|
||||||
|
|||||||
@ -1751,3 +1751,5 @@ WiFi签到延迟时长为±1分钟。
|
|||||||
你确定要删除子任务【(*)】吗?
|
你确定要删除子任务【(*)】吗?
|
||||||
你确定要归档子任务【(*)】吗?
|
你确定要归档子任务【(*)】吗?
|
||||||
你确定要还原归档子任务【(*)】吗?
|
你确定要还原归档子任务【(*)】吗?
|
||||||
|
|
||||||
|
请使用(*)移动端扫描二维码。
|
||||||
|
|||||||
@ -2,64 +2,79 @@
|
|||||||
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
use Orhanerday\OpenAi\OpenAi;
|
use Orhanerday\OpenAi\OpenAi;
|
||||||
|
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
|
|
||||||
|
|
||||||
try {
|
// 读取所有要翻译的内容
|
||||||
// 译文
|
$array = [];
|
||||||
$translations = [];
|
foreach (['api', 'web'] as $type) {
|
||||||
if (file_exists( "translate.json")) {
|
$content = file_exists("original-{$type}.txt") ? file_get_contents("original-{$type}.txt") : "";
|
||||||
|
$array = array_merge($array, array_values(array_filter(array_unique(explode("\n", $content)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判定是否存在translate.json文件
|
||||||
|
if (!file_exists("translate.json")) {
|
||||||
|
print_r("translate.json not exists");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$translations = []; // 翻译数据
|
||||||
|
$regrror = []; // 正则匹配错误的数据
|
||||||
|
$redundants = []; // 多余的数据
|
||||||
|
$needs = []; // 需要翻译的数据
|
||||||
|
|
||||||
$tmps = json_decode(file_get_contents("translate.json"), true);
|
$tmps = json_decode(file_get_contents("translate.json"), true);
|
||||||
foreach ($tmps as $tmp) {
|
foreach ($tmps as $tmp) {
|
||||||
if (!isset($tmp['key'])) {
|
if (!isset($tmp['key'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$translations[$tmp['key']] = $tmp;
|
$key = $tmp['key'];
|
||||||
|
$translations[$key] = $tmp;
|
||||||
|
if (in_array($key, $array)) {
|
||||||
|
$count = substr_count($key, '(*)');
|
||||||
|
if ($count > 0) {
|
||||||
|
foreach ($tmp as $k => $v) {
|
||||||
|
if ($k == 'zh' || $k == 'key') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($count != substr_count($v, '(*)')) {
|
||||||
|
$regrror[$key] = $tmp;
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$redundants[$key] = $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (['api', 'web'] as $type) {
|
|
||||||
// 读取文件
|
|
||||||
$content = file_exists("original-{$type}.txt") ? file_get_contents("original-{$type}.txt") : "";
|
|
||||||
$array = array_values(array_filter(array_unique(explode("\n", $content))));
|
|
||||||
// 提取要翻译的
|
|
||||||
$datas = [];
|
|
||||||
$needs = [];
|
|
||||||
foreach ($array as $text) {
|
foreach ($array as $text) {
|
||||||
$text = trim($text);
|
$key = trim($text);
|
||||||
if ($tmp = json_decode($text, true)) {
|
if (!isset($translations[$key])) {
|
||||||
$key = key($tmp);
|
$needs[$key] = $key;
|
||||||
$value = current($tmp);
|
|
||||||
} else {
|
|
||||||
$key = $value = $text;
|
|
||||||
}
|
|
||||||
if (isset($translations[$key])) {
|
|
||||||
$datas[] = $translations[$key];
|
|
||||||
} else {
|
|
||||||
$needs[$key] = $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($needs) > 0) {
|
||||||
$waits = array_chunk($needs, 100, true);
|
$waits = array_chunk($needs, 100, true);
|
||||||
// 分组翻译
|
foreach ($waits as $index => $items) {
|
||||||
foreach ($waits as $items) {
|
if ($index > 0) {
|
||||||
print_r(implode("\n", array_values($items)));
|
print_r("\n");
|
||||||
print_r("\n\n-------------------\n\n");
|
}
|
||||||
|
print_r("正在翻译:" . count($items) . "/" . count($needs) . "\n");
|
||||||
$content = implode("\n", $items);
|
$content = implode("\n", $items);
|
||||||
$open_ai = new OpenAi(OPEN_AI_KEY);
|
$open_ai = new OpenAi(OPEN_AI_KEY);
|
||||||
$open_ai->setProxy(OPEN_AI_PROXY);
|
$open_ai->setProxy(OPEN_AI_PROXY);
|
||||||
|
|
||||||
$chat = $open_ai->chat([
|
$chat = $open_ai->chat([
|
||||||
'model' => 'gpt-4o',
|
'model' => 'gpt-4o',
|
||||||
'messages' => [
|
'messages' => [
|
||||||
[
|
[
|
||||||
"role" => "user",
|
"role" => "system",
|
||||||
"content" => $content . '
|
"content" => <<<EOF
|
||||||
|
你是一个专业的翻译器,翻译的结果尽量符合“项目任务管理系统”的使用,将提供的文本按每行一个翻译成:
|
||||||
------
|
```json
|
||||||
|
|
||||||
请帮我翻译以上内容,翻译的结果尽量符合“项目任务管理系统”的使用,每行一个,按照下面的格式翻译成对应的语言,原内容放到key,zh留空,zh-CHT为繁体中文,en为英语,ko为韩语,ja为日语,de为德语,fr为法语,id为印度尼西亚语,ru为俄语。 另外要注意的是其中的(*)为占位符,翻译时不要删除,也不要翻译这个占位符。 请帮我一次性翻译完。
|
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"key": "",
|
"key": "",
|
||||||
@ -72,8 +87,16 @@ try {
|
|||||||
"fr": "",
|
"fr": "",
|
||||||
"id": "",
|
"id": "",
|
||||||
"ru": ""
|
"ru": ""
|
||||||
},
|
}
|
||||||
]'
|
]
|
||||||
|
```
|
||||||
|
key:原文本,zh:留空(不用翻译),zh-CHT:繁体中文,en:英语,ko:韩语,ja:日语,de:德语,fr:法语,id:印度尼西亚语,ru:俄语。
|
||||||
|
另外要注意的是其中的(*)为占位符,翻译时不要删除,也不要翻译这个占位符。请直接返回文本不需要使用markdown。
|
||||||
|
EOF,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"role" => "user",
|
||||||
|
"content" => $content,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'temperature' => 1.0,
|
'temperature' => 1.0,
|
||||||
@ -81,13 +104,41 @@ try {
|
|||||||
'frequency_penalty' => 0,
|
'frequency_penalty' => 0,
|
||||||
'presence_penalty' => 0,
|
'presence_penalty' => 0,
|
||||||
]);
|
]);
|
||||||
|
$obj = json_decode($chat);
|
||||||
$d = json_decode($chat);
|
$arr = json_decode($obj->choices[0]->message->content, true);
|
||||||
file_put_contents('translate-gpt.md', $d->choices[0]->message->content . "\n\n\n", FILE_APPEND);
|
if (!$arr || !is_array($arr)) {
|
||||||
}
|
print_r("翻译失败:\n");
|
||||||
|
print_r($content . "\n");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
foreach ($arr as $item) {
|
||||||
print_r("[$type] error, " . $e->getMessage());
|
foreach (['key', 'zh', 'zh-CHT', 'en', 'ko', 'ja', 'de', 'fr', 'id', 'ru'] as $lang) {
|
||||||
|
if (!isset($item[$lang])) {
|
||||||
|
print_r("翻译结果不符合规范:{$item['key']},缺少:{$lang}\n");
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($item['key'])) {
|
||||||
|
print_r("翻译结果不符合规范:{$item['key']},key为空\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$count = substr_count($item['key'], '(*)');
|
||||||
|
if ($count > 0) {
|
||||||
|
foreach ($item as $k => $v) {
|
||||||
|
if ($k == 'zh' || $k == 'key') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($count != substr_count($v, '(*)')) {
|
||||||
|
print_r("翻译结果不符合规范:{$item['key']},正则匹配错误:{$k} => {$v}\n");
|
||||||
|
continue 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item['zh'] = "";
|
||||||
|
$translations[$item['key']] = $item;
|
||||||
|
}
|
||||||
|
file_put_contents("translate.json", json_encode(array_values($translations), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
||||||
|
print_r("翻译完成:" . count($items) . "/" . count($needs) . "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
"stylus-loader": "^7.1.0",
|
"stylus-loader": "^7.1.0",
|
||||||
"tinymce": "^5.10.3",
|
"tinymce": "^5.10.3",
|
||||||
"tui-calendar-hi": "^1.15.1-5",
|
"tui-calendar-hi": "^1.15.1-5",
|
||||||
"view-design-hi": "^4.7.0-56",
|
"view-design-hi": "^4.7.0-57",
|
||||||
"vite": "^2.9.15",
|
"vite": "^2.9.15",
|
||||||
"vite-plugin-file-copy": "^1.0.0",
|
"vite-plugin-file-copy": "^1.0.0",
|
||||||
"vite-plugin-require": "^1.1.10",
|
"vite-plugin-require": "^1.1.10",
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<Tabs v-else v-model="aibotTabAction">
|
<Tabs v-else v-model="aibotTabAction" class="ai-tabs">
|
||||||
<TabPane label="ChatGPT" name="opanai">
|
<TabPane label="ChatGPT" name="opanai">
|
||||||
<div class="aibot-warp">
|
<div class="aibot-warp">
|
||||||
<SystemAibot type="ChatGPT" v-if="aibotTabAction == 'opanai'" />
|
<SystemAibot type="ChatGPT" v-if="aibotTabAction == 'opanai'" />
|
||||||
|
|||||||
38
resources/assets/sass/pages/page-apply.scss
vendored
38
resources/assets/sass/pages/page-apply.scss
vendored
@ -319,24 +319,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
.ivu-tabs {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0 -30px;
|
|
||||||
|
|
||||||
.ivu-tabs-bar {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ivu-tabs-content {
|
|
||||||
height: 100%;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
.ivu-modal-wrap-ul {
|
.ivu-modal-wrap-ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -421,12 +403,32 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 机器人
|
// 机器人
|
||||||
|
.ai-tabs {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.ivu-tabs-bar {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ivu-tabs-content {
|
||||||
|
height: 0;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
.aibot-warp {
|
.aibot-warp {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mobile-scan-login-box {
|
.mobile-scan-login-box {
|
||||||
margin: 2px 0 12px;
|
margin: 2px 0 12px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user