From 432f4c2f66965156d78b41c32ef7affa68f5877f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=B8=EB=B9=88?= Date: Thu, 5 Dec 2024 13:46:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B1=84=ED=8C=85=20=EB=B2=88=EC=97=AD?= =?UTF-8?q?=EC=9D=B4=20=EC=95=88=EB=90=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 채팅에 번역이 안되는 문장이 있을 경우 원래 문자열이 반환된다. --- chatServer/utils/translation.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chatServer/utils/translation.ts b/chatServer/utils/translation.ts index 68ea711..a5e8756 100644 --- a/chatServer/utils/translation.ts +++ b/chatServer/utils/translation.ts @@ -55,13 +55,16 @@ async function translate(text, lang?) { if (results[idx].match(/event:result/)) { const result = results[idx].match(/data:(.+)/); const data = JSON.parse(result[1]); - const translates = data.message.content.split('\n').reduce((obj, cur) => { + const content = data.message.content; + + const translates = content.split('\n').reduce((obj, cur) => { const [key, value] = cur.split(':'); + if (!translationMap.has(key)) return obj; obj[key.trim()] = value.trim(); return obj; }, {}); - return translates[translationMap.get(lang)]; + return translates[translationMap.get(lang)] ?? text; } }