Skip to content

Commit dbf1b2d

Browse files
committed
task(auth): Configure email renderer to use auth.ftl for now
Because: - We are still working with the l10n team to get emails translations squared away. - We can't finalize this process until we fully stop using the email templates in auth server This Commit: - Tells the email render in auth-server to look for translations in auth server's auth.ftl file.
1 parent 44a0fb3 commit dbf1b2d

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

libs/accounts/email-renderer/src/l10n.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { determineLocale, parseAcceptLanguage } from '@fxa/shared/l10n';
99
export type LocalizerOpts = {
1010
translations: {
1111
basePath: string;
12+
ftlFileName: string;
1213
};
1314
templates: {
1415
cssPath: string;
@@ -135,17 +136,14 @@ class Localizer {
135136
*/
136137
protected async fetchTranslatedMessages(locale?: string) {
137138
const results: string[] = [];
139+
const basePath = this.bindings.opts.translations.basePath;
140+
const ftlFileName = this.bindings.opts.translations.ftlFileName;
138141

139142
// Note: 'en' auth.ftl only exists for browser bindings / Storybook. The fallback
140143
// English strings within the templates are tested and are shown in other envs
141-
const authPath = `${this.bindings.opts.translations.basePath}/${
142-
locale || 'en'
143-
}/emails.ftl`;
144-
results.push(await this.bindings.fetchResource(authPath));
145-
146-
const brandingPath = `${this.bindings.opts.translations.basePath}/${
147-
locale || 'en'
148-
}/branding.ftl`;
144+
const mainFtlPath = `${basePath}/${locale || 'en'}/${ftlFileName}`;
145+
const brandingPath = `${basePath}/${locale || 'en'}/branding.ftl`;
146+
results.push(await this.bindings.fetchResource(mainFtlPath));
149147
results.push(await this.bindings.fetchResource(brandingPath));
150148

151149
return results.join('\n\n\n');

libs/accounts/email-renderer/src/renderer/bindings-browser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class BrowserRendererBindings extends RendererBindings {
5858
},
5959
translations: {
6060
basePath: './public/locales',
61+
ftlFileName: 'emails.ftl',
6162
},
6263
},
6364
opts

libs/accounts/email-renderer/src/renderer/bindings-node.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class NodeRendererBindings extends RendererBindings {
4545
},
4646
translations: {
4747
basePath: join(__dirname, '../../public/locales'),
48+
ftlFileName: 'emails.ftl',
4849
},
4950
},
5051
opts

packages/fxa-auth-server/bin/key_server.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require('../lib/monitoring');
1010
const { config } = require('../config');
1111

1212
const Redis = require('ioredis');
13-
13+
const { join } = require('node:path');
1414
const { CapabilityManager } = require('@fxa/payments/capability');
1515
const { EligibilityManager } = require('@fxa/payments/eligibility');
1616
const {
@@ -377,7 +377,15 @@ async function run(config) {
377377
emailSender,
378378
linkBuilder,
379379
config.smtp,
380-
new NodeRendererBindings()
380+
new NodeRendererBindings({
381+
translations: {
382+
// TODO: Once this PR, https://github.com/mozilla/fxa-content-server-l10n/pull/989, is finalized we can:
383+
// - switch this to point libs/accounts/public/locales or ../public/locales (either is probably fine...)
384+
// - switch to using emails.ftl, since all email specific strings will have been migrated over
385+
basePath: join(__dirname, '../public/locales'),
386+
ftlFileName: 'auth.ftl',
387+
},
388+
})
381389
);
382390
Container.set(FxaMailer, fxaMailer);
383391

0 commit comments

Comments
 (0)