/** * Lets the emails speak the instance's language from the same catalogs as * the interface. Their messages are written in `api/mail/` as * `i18n._({ id, message }, values)`, which `lingui extract` collects into * `locales/.po` beside the interface's and `lingui compile` turns into * the `locales/.mjs` imported here. The ids are spelled out, since the * server runs no Lingui macro to hash them. * * @module */ import { type I18n, type Messages, setupI18n } from "@lingui/core"; import { EMAIL_LOCALE } from "../config.ts"; import { LOCALES } from "../../shared/locale.ts"; const catalogs: [string, Messages][] = await Promise.all( LOCALES.map(async (locale) => [ locale, (await import(`../../locales/${locale}.mjs`)).messages as Messages, ] as [string, Messages] ), ); /** * Translates the emails' messages, in {@link EMAIL_LOCALE}. Every catalog is * loaded, so a test can activate another language. */ export const i18n: I18n = setupI18n({ locale: EMAIL_LOCALE, messages: Object.fromEntries(catalogs), });