作者 赵彬吉

聚合页 翻译

... ... @@ -717,7 +717,7 @@ class RelayInquiry extends Command
$project = Project::getProjectByDomain($domain);
if (empty($project)) {
$this->logChannel()->info('广告任务ID:' . $task['id'] . ', 转发对象:' . $re_website . '非v6链接,转发失败;', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]);
return [[], $lang];
return [[], $lang, ''];
}
$lang = WebLanguage::getLangById($project->main_lang_id ?? 1)['short'];
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\Tdk;
use App\Exceptions\ValidateException;
use App\Helper\Arr;
use App\Helper\Gpt;
use App\Helper\Translate;
use App\Models\Ai\AiCommand;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateNotify;
... ... @@ -14,6 +15,7 @@ use App\Models\Project\AggregateKeywordAffix;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\ProjectKeywordAiTask;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -51,6 +53,8 @@ class KeywordPageAiContent extends Command
'折线图',
];
protected $project;
/**
* @return bool
*/
... ... @@ -66,7 +70,7 @@ class KeywordPageAiContent extends Command
echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
$this->project = ProjectServer::useProject($project_id);
$update_rows = $this->ai_content($task);
... ... @@ -195,11 +199,15 @@ class KeywordPageAiContent extends Command
shuffle($suffix);
//标题(title):{聚合页扩展标题前缀} keywords {聚合页扩展标题后缀} {聚合页扩展标题后缀}
return sprintf('%s %s %s %s', $prefix[0], $title, $suffix[0], $suffix[1]);
$title = sprintf('%s %s %s %s', $prefix[0], $title, $suffix[0], $suffix[1]);
$lang = WebLanguage::getLangById($this->project['main_lang_id']??1);
return Translate::translate($title, $lang['short']);
}
public function ai_send($title, $company_description, $prompt)
public function ai_send($title, $company_description, $prompt, $lang)
{
if (strpos($prompt, '{title}') !== false) {
$prompt = str_replace('{title}', $title, $prompt);
... ... @@ -211,6 +219,11 @@ class KeywordPageAiContent extends Command
shuffle($this->chart_types);
$prompt = str_replace('{chart_type}', $this->chart_types[0], $prompt);
}
if (strpos($prompt, '{lang}') !== false) {
$lang = WebLanguage::getLangById($this->project['main_lang_id']??1);
$lang = $lang['english'] ?? 'English';
$prompt = str_replace('{lang}', $lang, $prompt);
}
$text = Gpt::instance()->openai_chat_qqs($prompt);
if (!$text) {
... ...