Сейчас я использую Google Glossary Translate.
Я добавил глоссарий, содержание
Код: Выделить всё
{
"glossaryEntries": [
{
"name": "projects/521859549804/locations/us-central1/glossaries/test-1-zh-CN-en/glossaryEntries/719985033120439992",
"termsSet": {
"terms": [
{
"languageCode": "zh-CN",
"text": "叶新"
},
{
"languageCode": "en",
"text": "Sammy Yare"
}
]
}
}
]
}
Код: Выделить всё
function getContent(){
return '
这么维护叶新”
叶新朝它
叶新冲过去
叶新乐呵呵
';
}
Код: Выделить всё
{
"translations": [
{
"translatedText": "\r\nSeeing Long Yalin defending Ye Xin so much, she let go of Ye Xin, and then said to Ye Xin: "Ye Xin, right? Remember my name! My name is Li Tianyu!" Ye Xin shot at it. Ye Xin rushed over and hugged her. Ye Xin was happy.\r\n"
}
],
"glossaryTranslations": [
{
"translatedText": "\r\nSeeing Long Yalin defending Sammy Yare so much, she let go of Sammy Yare, and then said to Sammy Yare: "Sammy Yare, right? Remember my name! My name is Li Tianyu!" Ye Xin shot at it. Ye Xin rushed over and hugged her. Ye Xin was happy.\r\n",
"glossaryConfig": {
"glossary": "projects/521859549804/locations/us-central1/glossaries/test-1-zh-CN-en"
}
}
]
}
< /code>
Очевидно видеть < /p>
[list]
[*] "叶新朝 它" li>
"叶新冲过去" переводится как "Е Синь подбежал и обнял ее".
[*]"叶新乐呵呵" переводится как "Е Синь был счастлив"< /li>
[/list]
То, что я хочу, должно быть
[list]
"叶新朝它" переводится как "Сэмми Яр выстрелил в нее"
[*]"叶新冲过去" переводится как "Сэмми Яр подбежал и обнял ее".
[*]"叶新乐呵呵" переводится на «Сэмми Йар был счастлив»
[/list]
Правильен только первый перевод.
Код выполнения следующий< /p>
function curlTranslateText($glossaryId,$contents,$sourceLanguageCode,$targetLanguageCode){
$url = 'https://translation.googleapis.com/v3/projects/'.$GLOBALS["projectId"].'/locations/us-central1:translateText';
$data = [
"sourceLanguageCode" => $sourceLanguageCode,
"targetLanguageCode" => $targetLanguageCode,
"contents" => $contents,
"glossaryConfig" => [
"glossary" => "projects/".$GLOBALS["projectId"]."/locations/us-central1/glossaries/".$glossaryId,
"ignoreCase" => false,
]
];
$res = google_auth_curl($url,"POST",json_encode($data),getHeader());
echo $res;
exit();
}
Как определить приоритетность содержания глоссария во время перевода
Подробнее здесь: https://stackoverflow.com/questions/788 ... ry-content
Мобильная версия