From b84621f9b2b7161a5ad4f0b194264e9df3e65dbf Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 8 Jul 2025 11:23:40 +0000 Subject: (대표님) 20250708 미반영분 커밋 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/mail/sendEmail.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/mail/sendEmail.ts') diff --git a/lib/mail/sendEmail.ts b/lib/mail/sendEmail.ts index 3f88cb04..b4d2707a 100644 --- a/lib/mail/sendEmail.ts +++ b/lib/mail/sendEmail.ts @@ -29,14 +29,23 @@ export async function sendEmail({ // i18n 설정 const { t, i18n } = await useTranslation(context.language ?? "en", "translation"); - // t 헬퍼만 동적으로 등록 (이미 mailer.ts에서 기본 등록되어 있지만, 언어별로 다시 등록) + // t 헬퍼를 언어별로 동적으로 재등록 (기존 헬퍼 덮어쓰기) + // 헬퍼가 이미 등록되어 있더라도 안전하게 재등록 + handlebars.unregisterHelper('t'); // 기존 헬퍼 제거 handlebars.registerHelper("t", function (key: string, options: any) { // 여기서 i18n은 로컬 인스턴스 - return i18n.t(key, options.hash || {}); + return i18n.t(key, options?.hash || {}); }); + // 템플릿 데이터에 i18n 인스턴스와 번역 함수 추가 + const templateData = { + ...context, + t: (key: string, options?: any) => i18n.t(key, options || {}), + i18n: i18n + }; + // 템플릿 컴파일 및 HTML 생성 - const html = loadTemplate(template, context); + const html = loadTemplate(template, templateData); // 이메일 발송 const result = await transporter.sendMail({ -- cgit v1.2.3