From 32bdaf3f234dde908aa6dddd71dbae26e30a146b Mon Sep 17 00:00:00 2001 From: wangliang Date: Fri, 23 Oct 2026 14:57:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(bridge):=20=E8=BD=AC=E4=BA=BA=E5=B7=A5?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8F=AA=E8=BE=93=E5=87=BA=E5=8D=95=E4=B8=80?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=B9=B6=E8=A1=A5=E9=BD=90=20es/tr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridge/src/escalation.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bridge/src/escalation.js b/bridge/src/escalation.js index 04b9b02..92c4088 100644 --- a/bridge/src/escalation.js +++ b/bridge/src/escalation.js @@ -17,17 +17,24 @@ function createEscalation({ client, handoffUserId = 1 }) { const text = String(reply || '').replace(/\s+$/, ''); const hints = { zh: '您想转人工客服吗?', + en: 'Would you like to speak to a human agent?', de: 'Möchten Sie mit einem Mitarbeiter sprechen?', fr: 'Souhaitez-vous parler à un conseiller ?', it: 'Vuole parlare con un operatore?', nl: 'Wilt u met een medewerker spreken?', + es: '¿Desea hablar con un agente humano?', + tr: 'Bir insan temsilcisiyle görüşmek ister misiniz?', }; + // 只输出一种语言:按用户输入判断语言,识别不到时用英文;不再拼英文兜底。 let lang = null; if (/[\u4e00-\u9fff]/.test(query)) lang = 'zh'; + else if (/[ğışç]/i.test(query) || /\b(merhaba|istiyorum|konuşmak|temsilci|fiyat|ürün|sipariş)\b/i.test(query)) lang = 'tr'; else if (/[äöüß]/i.test(query)) lang = 'de'; - else if (/[éèêëàâùûîïôç]/i.test(query)) lang = 'fr'; + else if (/[ñ¿¡]/i.test(query) || /\b(hola|quiero|hablar|agente|puedo|gracias|precio|pedido)\b/i.test(query)) lang = 'es'; + else if (/\b(vorrei|parlare|operatore|desidera|posso|prezzo|ordine)\b/i.test(query)) lang = 'it'; + else if (/[éèêëàâùûîïôç]/i.test(query) || /\b(bonjour|merci|conseiller|commande|livraison|prix|voudrais)\b/i.test(query)) lang = 'fr'; else if (/\b(hoe|voor|wilt|bent|geen|verzending|levering|bestelling)\b/i.test(query)) lang = 'nl'; - const option = lang ? `\n\n${hints[lang]} / Would you like to speak to a human agent?` : '\n\nWould you like to speak to a human agent?'; + const option = `\n\n${hints[lang] || hints.en}`; return text + option; }