-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<p align="center"> | ||
<img src="https://github.com/midday-ai/languine/blob/main/packages/react-email/image.png" /> | ||
</p> | ||
|
||
<p align="center"> | ||
A lightweight i18n library for React email templates. | ||
</p> | ||
|
||
--- | ||
|
||
```bash | ||
$ npm install @languine/react-email | ||
``` | ||
|
||
## What is this? | ||
|
||
This is a lightweight i18n library for React email templates. It is built on top of `i18n-js`. | ||
|
||
Automatically included language files are in the `locales` folder. | ||
|
||
## How to use | ||
|
||
```tsx | ||
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> | ||
); | ||
} | ||
``` | ||
|
||
### Rendering the email | ||
```tsx | ||
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](https://languine.ai). | ||
|
||
```bash | ||
$ npx languine@latest | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters