作者 赵彬吉

聚合页 翻译

@@ -717,7 +717,7 @@ class RelayInquiry extends Command @@ -717,7 +717,7 @@ class RelayInquiry extends Command
717 $project = Project::getProjectByDomain($domain); 717 $project = Project::getProjectByDomain($domain);
718 if (empty($project)) { 718 if (empty($project)) {
719 $this->logChannel()->info('广告任务ID:' . $task['id'] . ', 转发对象:' . $re_website . '非v6链接,转发失败;', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]); 719 $this->logChannel()->info('广告任务ID:' . $task['id'] . ', 转发对象:' . $re_website . '非v6链接,转发失败;', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]);
720 - return [[], $lang]; 720 + return [[], $lang, ''];
721 } 721 }
722 $lang = WebLanguage::getLangById($project->main_lang_id ?? 1)['short']; 722 $lang = WebLanguage::getLangById($project->main_lang_id ?? 1)['short'];
723 723
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Tdk; @@ -5,6 +5,7 @@ namespace App\Console\Commands\Tdk;
5 use App\Exceptions\ValidateException; 5 use App\Exceptions\ValidateException;
6 use App\Helper\Arr; 6 use App\Helper\Arr;
7 use App\Helper\Gpt; 7 use App\Helper\Gpt;
  8 +use App\Helper\Translate;
8 use App\Models\Ai\AiCommand; 9 use App\Models\Ai\AiCommand;
9 use App\Models\Com\NoticeLog; 10 use App\Models\Com\NoticeLog;
10 use App\Models\Com\UpdateNotify; 11 use App\Models\Com\UpdateNotify;
@@ -14,6 +15,7 @@ use App\Models\Project\AggregateKeywordAffix; @@ -14,6 +15,7 @@ use App\Models\Project\AggregateKeywordAffix;
14 use App\Models\Project\DeployBuild; 15 use App\Models\Project\DeployBuild;
15 use App\Models\Project\DeployOptimize; 16 use App\Models\Project\DeployOptimize;
16 use App\Models\Project\ProjectKeywordAiTask; 17 use App\Models\Project\ProjectKeywordAiTask;
  18 +use App\Models\WebSetting\WebLanguage;
17 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
18 use Illuminate\Console\Command; 20 use Illuminate\Console\Command;
19 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
@@ -51,6 +53,8 @@ class KeywordPageAiContent extends Command @@ -51,6 +53,8 @@ class KeywordPageAiContent extends Command
51 '折线图', 53 '折线图',
52 ]; 54 ];
53 55
  56 + protected $project;
  57 +
54 /** 58 /**
55 * @return bool 59 * @return bool
56 */ 60 */
@@ -66,7 +70,7 @@ class KeywordPageAiContent extends Command @@ -66,7 +70,7 @@ class KeywordPageAiContent extends Command
66 70
67 echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL; 71 echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
68 try { 72 try {
69 - ProjectServer::useProject($project_id); 73 + $this->project = ProjectServer::useProject($project_id);
70 74
71 $update_rows = $this->ai_content($task); 75 $update_rows = $this->ai_content($task);
72 76
@@ -195,11 +199,15 @@ class KeywordPageAiContent extends Command @@ -195,11 +199,15 @@ class KeywordPageAiContent extends Command
195 shuffle($suffix); 199 shuffle($suffix);
196 //标题(title):{聚合页扩展标题前缀} keywords {聚合页扩展标题后缀} {聚合页扩展标题后缀} 200 //标题(title):{聚合页扩展标题前缀} keywords {聚合页扩展标题后缀} {聚合页扩展标题后缀}
197 201
198 - return sprintf('%s %s %s %s', $prefix[0], $title, $suffix[0], $suffix[1]); 202 + $title = sprintf('%s %s %s %s', $prefix[0], $title, $suffix[0], $suffix[1]);
  203 +
  204 + $lang = WebLanguage::getLangById($this->project['main_lang_id']??1);
  205 +
  206 + return Translate::translate($title, $lang['short']);
199 } 207 }
200 208
201 209
202 - public function ai_send($title, $company_description, $prompt) 210 + public function ai_send($title, $company_description, $prompt, $lang)
203 { 211 {
204 if (strpos($prompt, '{title}') !== false) { 212 if (strpos($prompt, '{title}') !== false) {
205 $prompt = str_replace('{title}', $title, $prompt); 213 $prompt = str_replace('{title}', $title, $prompt);
@@ -211,6 +219,11 @@ class KeywordPageAiContent extends Command @@ -211,6 +219,11 @@ class KeywordPageAiContent extends Command
211 shuffle($this->chart_types); 219 shuffle($this->chart_types);
212 $prompt = str_replace('{chart_type}', $this->chart_types[0], $prompt); 220 $prompt = str_replace('{chart_type}', $this->chart_types[0], $prompt);
213 } 221 }
  222 + if (strpos($prompt, '{lang}') !== false) {
  223 + $lang = WebLanguage::getLangById($this->project['main_lang_id']??1);
  224 + $lang = $lang['english'] ?? 'English';
  225 + $prompt = str_replace('{lang}', $lang, $prompt);
  226 + }
214 227
215 $text = Gpt::instance()->openai_chat_qqs($prompt); 228 $text = Gpt::instance()->openai_chat_qqs($prompt);
216 if (!$text) { 229 if (!$text) {