diff --git a/README.md b/README.md index c81cf7c..7bfc051 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 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) @@ -22,6 +22,23 @@ For simple usage examples, see the [main package readme](/packages/core/README.m --- +### 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;