From 11bce786b8e8af290913c7d2ee3dc15f68924cb9 Mon Sep 17 00:00:00 2001 From: jungpaeng Date: Sun, 1 Oct 2023 18:58:52 +0900 Subject: [PATCH] feat: export package --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 5 ++--- 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..53aa596 --- /dev/null +++ b/README.md @@ -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 ( + <> + {t('latestFollower', {username: user.name})} + } /> + + ); +} +``` + +```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 ( + + + + ); +} +``` +3. Based on the features you need, you might have to provide [polyfills](https://formatjs.io/docs/polyfills). +4. Use translations in your components! + diff --git a/src/index.ts b/src/index.ts index 508f35f..052074c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,2 @@ -export function sum(a: number, b: number) { - return a + b; -} +export * from './lit-intl.provider'; +export * from './use-translation';