Skip to content

Commit

Permalink
feat: export package
Browse files Browse the repository at this point in the history
  • Loading branch information
jungpaeng committed Oct 1, 2023
1 parent 9cc249a commit 11bce78
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# lit-intl

[![Stable release](https://img.shields.io/npm/v/lit-intl.svg)](https://npm.im/lit-intl)

This is minimal i18n for react package.

```jsx
function Follower({user}) {
const t = useTranslation('Follower');

return (
<>
<Text>{t('latestFollower', {username: user.name})}</Text>
<IconButton aria-label={t('followBack')} icon={<FollowIcon />} />
</>
);
}
```

```js
// en.json
{
"Follower": {
"latestFollower": "{username} started following you",
"followBack": "Follow back"
}
}
```

## Features

- This library is a thin wrapper around a high-quality API for i18n built on top of [Format.JS](https://formatjs.io/).
- Integrate with React with minimal configuration.

## Installation

1. Install `lit-intl` in your project
2. Add the provider your top code
```jsx
import {LitIntlProvider} from 'lit-intl';

export default function App() {
return (
<LitIntlProvider messages={messages}>
<Component {...pageProps} />
</LitIntlProvider>
);
}
```
3. Based on the features you need, you might have to provide [polyfills](https://formatjs.io/docs/polyfills).
4. Use translations in your components!

5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export function sum(a: number, b: number) {
return a + b;
}
export * from './lit-intl.provider';
export * from './use-translation';

0 comments on commit 11bce78

Please sign in to comment.