From 754f6a8ba00f7229ee5543d87d743cbdb6e97e11 Mon Sep 17 00:00:00 2001 From: nzambello Date: Thu, 10 Oct 2024 16:11:20 +0300 Subject: [PATCH] fix: auto translate ui if not multilingual --- src/components/MemoriWidget/MemoriWidget.tsx | 15 ++++++++++++--- src/index.stories.tsx | 10 ++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/MemoriWidget/MemoriWidget.tsx b/src/components/MemoriWidget/MemoriWidget.tsx index b929879b..103893aa 100644 --- a/src/components/MemoriWidget/MemoriWidget.tsx +++ b/src/components/MemoriWidget/MemoriWidget.tsx @@ -505,7 +505,11 @@ const MemoriWidget = ({ * Sets the language in the i18n instance */ useEffect(() => { - if (userLang && uiLanguages.includes(userLang.toLowerCase())) { + if ( + isMultilanguageEnabled && + userLang && + uiLanguages.includes(userLang.toLowerCase()) + ) { // @ts-ignore i18n.changeLanguage(userLang.toLowerCase()); } @@ -1971,9 +1975,14 @@ const MemoriWidget = ({ //if there is an emotion, remove the tag from the text const textToSpeak = text.replace(/(.*?)<\/output>/g, '$1'); - speechSynthesizer.speakSsmlAsync(`${replaceTextWithPhonemes( + )}">${replaceTextWithPhonemes( escapeHTML(stripMarkdown(stripEmojis(stripOutputTags(textToSpeak)))), userLang.toLowerCase() )}`, diff --git a/src/index.stories.tsx b/src/index.stories.tsx index fa9c561b..335490ec 100644 --- a/src/index.stories.tsx +++ b/src/index.stories.tsx @@ -211,13 +211,11 @@ WithCustomUserAvatar.args = { export const Test = Template.bind({}); Test.args = { - ownerUserName: 'memoridev', - memoriName: 'Assistente Report', - tenantID: 'bcc-iccrea.aclambda.online', - apiURL: 'https://backend.memori.ai', - baseURL: 'https://bcc-iccrea.aclambda.online', + ownerUserName: 'dpezzettone', + memoriName: 'Meta Prompt Engineer', + tenantID: 'www.aisuru.com', layout: 'CHAT', - uiLang: 'it', + uiLang: 'en', showShare: true, showSettings: true, showLogin: true,