-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
54 additions
and
3 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,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! | ||
|
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
export * from './lit-intl.provider'; | ||
export * from './use-translation'; |