Skip to content

Commit

Permalink
Add simple usage example to root README too
Browse files Browse the repository at this point in the history
  • Loading branch information
Raiondesu committed Dec 20, 2023
1 parent 2b27b86 commit 58ab976
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,31 @@ A tiny framework-agnostic i18n library (1-3kb, zero-dependency) that allows to l

You can also install a nightly build [directly from github](#install-from-github)

For simple usage examples, see the [main package readme](/packages/core/README.md)
For more usage examples, see the [main package readme](/packages/core/README.md)

[List of packages](#packages)

</div>

---

### Simple usage example

```ts
import { createTranslator } from 'intl-schematic';

// Define a translation document factory
const getDocument = () => ({
"hello": "Hello, World!"
});

// Create a translator function (`t()`)
const t = createTranslator(getDocument);

// Use the translator function
console.log(t('hello')); // `Hello, World!`
```

## Features

- 🦺 **Full type-safety**: full autocomplete on translation keys, typed translation parameters and more;
Expand Down

0 comments on commit 58ab976

Please sign in to comment.