Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 28, 2024
1 parent afed98e commit b00894c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
60 changes: 60 additions & 0 deletions packages/react-email/README.md
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
```
Binary file added packages/react-email/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions packages/react-email/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@languine/react-email",
"version": "0.0.1",
"version": "0.1.0",
"files": ["dist", "README.md"],
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -12,14 +12,12 @@
"typecheck": "tsc --noEmit",
"build": "tsup --clean src/index.tsx"
},
"peerDependencies": {
"i18n-js": "^4.5.1"
},
"devDependencies": {
"tsup": "^8.3.5",
"typescript": "^5.7.2"
},
"dependencies": {
"i18n-js": "^4.5.1",
"react-string-replace": "^1.1.1"
}
}

0 comments on commit b00894c

Please sign in to comment.