feat: Ability to overwrite locale on contact level with locale key on data

This commit is contained in:
Dries Augustyns
2025-12-25 17:37:25 +01:00
parent fa9e9de032
commit 76155232a3
4 changed files with 45 additions and 4 deletions
+12 -2
View File
@@ -604,8 +604,18 @@ export class EmailService {
const unsubscribeHtml = includeUnsubscribe
? (() => {
// Get translator for project's language
const translator = createTranslatorSync(project.language || 'en');
// Get contact-level locale (overrides project language)
const contactLocale =
contact.data &&
typeof contact.data === 'object' &&
!Array.isArray(contact.data) &&
'locale' in contact.data &&
typeof contact.data.locale === 'string'
? contact.data.locale
: null;
// Get translator for contact's locale or project's language
const translator = createTranslatorSync(contactLocale || project.language || 'en');
const unsubscribeText = translator.t('email.footer.unsubscribeText', {
projectName: project.name,
});