feat: implement language-based email template selection
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 <noreply@anthropic.com>
This commit is contained in:
@@ -59,7 +59,7 @@ export async function sendVerificationRequests(db: Db, budget: number): Promise<
|
|||||||
'ownerName': ownerName,
|
'ownerName': ownerName,
|
||||||
'location.name': location.name,
|
'location.name': location.name,
|
||||||
'shareId': shareId
|
'shareId': shareId
|
||||||
});
|
}, location.tenantEmailLanguage || 'hr');
|
||||||
|
|
||||||
const success = await sendEmail({
|
const success = await sendEmail({
|
||||||
to: location.tenantEmail,
|
to: location.tenantEmail,
|
||||||
@@ -161,7 +161,7 @@ export async function sendRentDueNotifications(db: Db, budget: number): Promise<
|
|||||||
'currency': currency,
|
'currency': currency,
|
||||||
'ownerName': ownerName,
|
'ownerName': ownerName,
|
||||||
'shareId': shareId
|
'shareId': shareId
|
||||||
});
|
}, location.tenantEmailLanguage || 'hr');
|
||||||
|
|
||||||
const success = await sendEmail({
|
const success = await sendEmail({
|
||||||
to: location.tenantEmail,
|
to: location.tenantEmail,
|
||||||
@@ -254,7 +254,7 @@ export async function sendUtilityBillsNotifications(db: Db, budget: number): Pro
|
|||||||
'currency': currency,
|
'currency': currency,
|
||||||
'ownerName': ownerName,
|
'ownerName': ownerName,
|
||||||
'shareId': shareId
|
'shareId': shareId
|
||||||
});
|
}, location.tenantEmailLanguage || 'hr');
|
||||||
|
|
||||||
const success = await sendEmail({
|
const success = await sendEmail({
|
||||||
to: location.tenantEmail,
|
to: location.tenantEmail,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export type TemplateVariables = {
|
|||||||
* @param language Language code (default: 'en')
|
* @param language Language code (default: 'en')
|
||||||
* @returns Template content as string
|
* @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}`;
|
const cacheKey = `${templateName}--${language}`;
|
||||||
|
|
||||||
// Check cache first
|
// Check cache first
|
||||||
@@ -80,7 +80,7 @@ export function renderTemplate(template: string, variables: TemplateVariables):
|
|||||||
export function loadAndRender(
|
export function loadAndRender(
|
||||||
templateName: string,
|
templateName: string,
|
||||||
variables: TemplateVariables,
|
variables: TemplateVariables,
|
||||||
language: string = 'en'
|
language: string = 'hr'
|
||||||
): string {
|
): string {
|
||||||
const template = loadTemplate(templateName, language);
|
const template = loadTemplate(templateName, language);
|
||||||
return renderTemplate(template, variables);
|
return renderTemplate(template, variables);
|
||||||
|
|||||||
Reference in New Issue
Block a user