From 47df21322da52d8ce446c183fc36afdeac1b4d17 Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Thu, 29 Sep 2022 15:07:22 +0200 Subject: [PATCH] Fixes translation issue of dynamic variables in workflows (#4734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * replace all underscores for variable translations * use g instead of replaceAll Co-authored-by: CarinaWolli Co-authored-by: Omar López --- .../ee/workflows/components/v2/AddVariablesDropdown.tsx | 2 +- .../ee/workflows/components/v2/WorkflowStepContainer.tsx | 4 ++-- packages/features/ee/workflows/lib/variableTranslations.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/features/ee/workflows/components/v2/AddVariablesDropdown.tsx b/packages/features/ee/workflows/components/v2/AddVariablesDropdown.tsx index 0385bf57fa..42cd301c59 100644 --- a/packages/features/ee/workflows/components/v2/AddVariablesDropdown.tsx +++ b/packages/features/ee/workflows/components/v2/AddVariablesDropdown.tsx @@ -48,7 +48,7 @@ export const AddVariablesDropdown = (props: IAddVariablesDropdown) => { onClick={() => props.addVariable(props.isEmailSubject, t(`${variable}_workflow`))}>
- {`{${t(`${variable}_workflow`).toUpperCase().replace(" ", "_")}}`} + {`{${t(`${variable}_workflow`).toUpperCase().replace(/ /g, "_")}}`}
{t(`${variable}_info`)} diff --git a/packages/features/ee/workflows/components/v2/WorkflowStepContainer.tsx b/packages/features/ee/workflows/components/v2/WorkflowStepContainer.tsx index b8b3e119fa..2f85d45b8c 100644 --- a/packages/features/ee/workflows/components/v2/WorkflowStepContainer.tsx +++ b/packages/features/ee/workflows/components/v2/WorkflowStepContainer.tsx @@ -86,14 +86,14 @@ export default function WorkflowStepContainer(props: WorkflowStepProps) { const cursorPosition = refEmailSubject?.current?.selectionStart || currentEmailSubject.length; const subjectWithAddedVariable = `${currentEmailSubject.substring(0, cursorPosition)}{${variable .toUpperCase() - .replace(" ", "_")}}${currentEmailSubject.substring(cursorPosition)}`; + .replace(/ /g, "_")}}${currentEmailSubject.substring(cursorPosition)}`; form.setValue(`steps.${step.stepNumber - 1}.emailSubject`, subjectWithAddedVariable); } else { const currentMessageBody = refReminderBody?.current?.value || ""; const cursorPosition = refReminderBody?.current?.selectionStart || currentMessageBody.length; const messageWithAddedVariable = `${currentMessageBody.substring(0, cursorPosition)}{${variable .toUpperCase() - .replace(" ", "_")}}${currentMessageBody.substring(cursorPosition)}`; + .replace(/ /g, "_")}}${currentMessageBody.substring(cursorPosition)}`; form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, messageWithAddedVariable); } } diff --git a/packages/features/ee/workflows/lib/variableTranslations.ts b/packages/features/ee/workflows/lib/variableTranslations.ts index e2f546f042..db87f91a16 100644 --- a/packages/features/ee/workflows/lib/variableTranslations.ts +++ b/packages/features/ee/workflows/lib/variableTranslations.ts @@ -45,12 +45,12 @@ export function translateVariablesToEnglish(text: string, language: { locale: st originalVariables.forEach((originalVariable) => { const newVariableName = variable.replace("_NAME", ""); if ( - language.t(originalVariable).replace(/ /, "_").toUpperCase() === variable || - language.t(originalVariable).replace(/ /, "_").toUpperCase() === newVariableName + language.t(originalVariable).replace(/ /g, "_").toUpperCase() === variable || + language.t(originalVariable).replace(/ /g, "_").toUpperCase() === newVariableName ) { newText = newText.replace( variable, - language.t(originalVariable, { lng: "en" }).replace(" ", "_").toUpperCase() + language.t(originalVariable, { lng: "en" }).replace(/ /g, "_").toUpperCase() ); return; }