From f7b3467981a696ea31e7f30edd574214d3fe7e5c Mon Sep 17 00:00:00 2001 From: NoriDev Date: Mon, 2 Oct 2023 00:24:01 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20=E3=80=8C=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E3=82=92=E9=9A=A0=E3=81=99=E3=80=8D=E3=81=AB=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE?= =?UTF-8?q?=E6=B3=A8=E9=87=88=E3=82=82=E7=BF=BB=E8=A8=B3=E3=81=AB=E5=90=AB?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG_CHERRYPICK.md | 1 + .../backend/src/server/api/endpoints/notes/translate.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG_CHERRYPICK.md b/CHANGELOG_CHERRYPICK.md index 49a2958664..d5b77a77ce 100644 --- a/CHANGELOG_CHERRYPICK.md +++ b/CHANGELOG_CHERRYPICK.md @@ -39,6 +39,7 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2023xx](CHANGE ### Server - 이모티콘 중복 체크 (misskey-dev/misskey#11941) +- Enhance: '내용 숨기기'로 설정된 노트의 주석도 번역에 포함됨 --- diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index bf7398c08d..44885bad07 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -103,12 +103,12 @@ export default class extends Endpoint { // eslint- if (instance.deeplAuthKey == null) { return 204; // TODO: 良い感じのエラー返す } - translationResult = await this.translateDeepL(note.text, targetLang, instance.deeplAuthKey, instance.deeplIsPro, instance.translatorType); + translationResult = await this.translateDeepL((note.cw ? note.cw + '\n' : '') + note.text, targetLang, instance.deeplAuthKey, instance.deeplIsPro, instance.translatorType); } else if (instance.translatorType === 'google_no_api') { let targetLang = ps.targetLang; if (targetLang.includes('-')) targetLang = targetLang.split('-')[0]; - const { text, raw } = await translate(note.text, { to: targetLang }); + const { text, raw } = await translate((note.cw ? note.cw + '\n' : '') + note.text, { to: targetLang }); return { sourceLang: raw.src, @@ -119,7 +119,7 @@ export default class extends Endpoint { // eslint- if (instance.ctav3SaKey == null) { return 204; } else if (instance.ctav3ProjectId == null) { return 204; } else if (instance.ctav3Location == null) { return 204; } translationResult = await this.apiCloudTranslationAdvanced( - note.text, targetLang, instance.ctav3SaKey, instance.ctav3ProjectId, instance.ctav3Location, instance.ctav3Model, instance.ctav3Glossary, instance.translatorType, + (note.cw ? note.cw + '\n' : '') + note.text, targetLang, instance.ctav3SaKey, instance.ctav3ProjectId, instance.ctav3Location, instance.ctav3Model, instance.ctav3Glossary, instance.translatorType, ); } else { throw new Error('Unsupported translator type');