mirror of
https://github.com/hanzoai/sign.git
synced 2026-11-02 23:26:15 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
33 lines
947 B
TypeScript
33 lines
947 B
TypeScript
import type { RenderOptions } from '@hanzo/esign-email/render';
|
|
import { renderWithI18N } from '@hanzo/esign-email/render';
|
|
|
|
import { getI18nInstance } from '../client-only/providers/i18n-server';
|
|
import {
|
|
APP_I18N_OPTIONS,
|
|
type SupportedLanguageCodes,
|
|
isValidLanguageCode,
|
|
} from '../constants/i18n';
|
|
|
|
export const renderEmailWithI18N = async (
|
|
component: React.ReactElement,
|
|
options?: RenderOptions & {
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
lang?: SupportedLanguageCodes | (string & {});
|
|
},
|
|
) => {
|
|
try {
|
|
const { lang: providedLang, ...otherOptions } = options ?? {};
|
|
|
|
const lang = isValidLanguageCode(providedLang) ? providedLang : APP_I18N_OPTIONS.sourceLang;
|
|
|
|
const i18n = await getI18nInstance(lang);
|
|
|
|
i18n.activate(lang);
|
|
|
|
return renderWithI18N(component, { i18n, ...otherOptions });
|
|
} catch (err) {
|
|
console.error(err);
|
|
throw new Error('Failed to render email');
|
|
}
|
|
};
|