From d7abd99448b692a3af68d3f3742528722eb6a297 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Wed, 31 Dec 2025 11:07:39 +0100 Subject: [PATCH] feat: implement language-based email template selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update email worker to select templates based on BillingLocation.tenantEmailLanguage: - Change default language from 'en' to 'hr' in emailTemplates.ts - Pass language parameter (location.tenantEmailLanguage || 'hr') to all loadAndRender calls - Applies to email validation, rent due, and utility bills notifications Email templates are now automatically selected based on tenant's language preference, defaulting to Croatian when not specified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- email-worker/src/lib/emailSenders.ts | 6 +++--- email-worker/src/lib/emailTemplates.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/email-worker/src/lib/emailSenders.ts b/email-worker/src/lib/emailSenders.ts index e26c007..4721b73 100644 --- a/email-worker/src/lib/emailSenders.ts +++ b/email-worker/src/lib/emailSenders.ts @@ -59,7 +59,7 @@ export async function sendVerificationRequests(db: Db, budget: number): Promise< 'ownerName': ownerName, 'location.name': location.name, 'shareId': shareId - }); + }, location.tenantEmailLanguage || 'hr'); const success = await sendEmail({ to: location.tenantEmail, @@ -161,7 +161,7 @@ export async function sendRentDueNotifications(db: Db, budget: number): Promise< 'currency': currency, 'ownerName': ownerName, 'shareId': shareId - }); + }, location.tenantEmailLanguage || 'hr'); const success = await sendEmail({ to: location.tenantEmail, @@ -254,7 +254,7 @@ export async function sendUtilityBillsNotifications(db: Db, budget: number): Pro 'currency': currency, 'ownerName': ownerName, 'shareId': shareId - }); + }, location.tenantEmailLanguage || 'hr'); const success = await sendEmail({ to: location.tenantEmail, diff --git a/email-worker/src/lib/emailTemplates.ts b/email-worker/src/lib/emailTemplates.ts index a37ca4b..15a1b42 100644 --- a/email-worker/src/lib/emailTemplates.ts +++ b/email-worker/src/lib/emailTemplates.ts @@ -20,7 +20,7 @@ export type TemplateVariables = { * @param language Language code (default: 'en') * @returns Template content as string */ -export function loadTemplate(templateName: string, language: string = 'en'): string { +export function loadTemplate(templateName: string, language: string = 'hr'): string { const cacheKey = `${templateName}--${language}`; // Check cache first @@ -80,7 +80,7 @@ export function renderTemplate(template: string, variables: TemplateVariables): export function loadAndRender( templateName: string, variables: TemplateVariables, - language: string = 'en' + language: string = 'hr' ): string { const template = loadTemplate(templateName, language); return renderTemplate(template, variables);