feat: email workflow templates translation (#20674)
* Add translations in respective files * implement multilingual support for email templates * fix: indentation in common.js & typos in common.js and update.handler.ts
This commit is contained in:
1 parent
417acdaacb
commit
381c462660
52 files changed
+630
-76
No files matched your search
@@ -2,6 +2,7 @@ import type { Workflow } from "@prisma/client";
|
||||
|
||||
import emailReminderTemplate from "@calcom/ee/workflows/lib/reminders/templates/emailReminderTemplate";
|
||||
import { SENDER_NAME } from "@calcom/lib/constants";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
@@ -69,6 +70,7 @@ export const createHandler = async ({ ctx, input }: CreateOptions) => {
|
||||
const renderedEmailTemplate = emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale: ctx.user.locale,
|
||||
t: await getTranslation(ctx.user.locale, "common"),
|
||||
action: WorkflowActions.EMAIL_ATTENDEE,
|
||||
timeFormat: getTimeFormatStringFromUserTimeFormat(ctx.user.timeFormat),
|
||||
});
|
||||
|
||||
@@ -355,7 +355,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
|
||||
if (isEmailAction(newStep.action)) {
|
||||
// on free plans always use predefined templates
|
||||
const { emailBody, emailSubject } = getEmailTemplateText(newStep.template, {
|
||||
const { emailBody, emailSubject } = await getEmailTemplateText(newStep.template, {
|
||||
locale: ctx.user.locale,
|
||||
action: newStep.action,
|
||||
timeFormat: ctx.user.timeFormat,
|
||||
@@ -430,7 +430,7 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
}
|
||||
|
||||
// on free plans always use predefined templates
|
||||
const { emailBody, emailSubject } = getEmailTemplateText(newStep.template, {
|
||||
const { emailBody, emailSubject } = await getEmailTemplateText(newStep.template, {
|
||||
locale: ctx.user.locale,
|
||||
action: newStep.action,
|
||||
timeFormat: ctx.user.timeFormat,
|
||||
|
||||
@@ -20,6 +20,7 @@ import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
|
||||
import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
|
||||
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import { WorkflowRepository } from "@calcom/lib/server/repository/workflow";
|
||||
import { getTimeFormatStringFromUserTimeFormat } from "@calcom/lib/timeFormat";
|
||||
import prisma from "@calcom/prisma";
|
||||
@@ -865,7 +866,7 @@ export const getEventTypeWorkflows = async (
|
||||
return workflows.map((workflow) => ({ workflow }));
|
||||
};
|
||||
|
||||
export function getEmailTemplateText(
|
||||
export async function getEmailTemplateText(
|
||||
template: WorkflowTemplates,
|
||||
params: { locale: string; action: WorkflowActions; timeFormat: number | null }
|
||||
) {
|
||||
@@ -876,6 +877,7 @@ export function getEmailTemplateText(
|
||||
let { emailBody, emailSubject } = emailReminderTemplate({
|
||||
isEditingMode: true,
|
||||
locale,
|
||||
t: await getTranslation(locale ?? "en", "common"),
|
||||
action,
|
||||
timeFormat,
|
||||
});
|
||||
@@ -885,6 +887,7 @@ export function getEmailTemplateText(
|
||||
isEditingMode: true,
|
||||
locale,
|
||||
action,
|
||||
t: await getTranslation(locale ?? "en", "common"),
|
||||
timeFormat,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user