From 58ab976afa082a2ae62420e1c2e1cd8b977b9f9e Mon Sep 17 00:00:00 2001 From: Alexey Iskhakov Date: Wed, 20 Dec 2023 17:47:04 +0400 Subject: [PATCH] Add simple usage example to root README too --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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;