1.0.1 • Published 12 months ago

@languine/react-email v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

$ npm install @languine/react-email

What is this?

This is a lightweight i18n library for React Email built on top of i18n-js.

Language files are automatically included in the locales folder.

How to use

import { setupI18n } from "@languine/react-email";

export function WelcomeEmail({ locale, name }) {
  const i18n = setupI18n(locale);

  return (
    <Html>
      <Head />
      <Preview>{i18n.t("preview")}</Preview>
      <Body>
         <Text>{i18n.t("welcome", { name  })}</Text>
      </Body>
    </Html>
  );
}

Translation files (en.json)

Add your translation files in the locales folder.

{
    "preview": "Welcome to our app!",
    "welcome": "Hello, %{name}!"
}

Rendering the email

import { render } from '@react-email/render';
import { WelcomeEmail } from "./emails/welcome";

const html = await render(<WelcomeEmail locale="en" name="John" />, {
  pretty: true,
});

console.log(html);

Works together with Languine CLI

Automatically add and translate your email templates with Languine CLI.

$ npx languine@latest
1.0.1

12 months ago

1.0.0

12 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago

0.0.1

12 months ago