intl-schematic
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
{ | ||
"name": "intl-schematic", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -11,3 +11,3 @@ <h1 align="center"> | ||
A tiny library (3kb, zero-dependency) that allows to localize and format strings with infinitely expandable functionality. | ||
A tiny library (1kb, zero-dependency) that allows to localize and format strings with infinitely expandable functionality. | ||
@@ -18,9 +18,11 @@ </p> | ||
- 🎄 **Tree-shakable**: only take what you need; | ||
- 🔌 **Pluginable**: extend any processing step without limits; | ||
- 🔌 **Pluginable**: extend any processing step without limits - see the [plugins API](/packages/plugins/) for more; | ||
- 📃 **JSON-validation using a JSON-schema**: intellisense and popup hints right in the translation document; | ||
- 🚫 **No string-interpolation**: translation strings will never be processed or mangled by-default, so all unicode symbols are safe to use; | ||
## Table of contents<!-- omit from toc --> | ||
- [Define a translation document factory](#define-a-translation-document-factory) | ||
- [Create a translator function (`t()`)](#create-a-translator-function-t) | ||
- [Use a translator function](#use-a-translator-function) | ||
- [Use the translator function](#use-the-translator-function) | ||
- [Add default plugins and processors](#add-default-plugins-and-processors) | ||
@@ -30,4 +32,2 @@ | ||
Comprehensive documentation is in progress. | ||
See a simplified example below and don't be afraid to take a look into the sources to find out more. | ||
@@ -38,2 +38,4 @@ | ||
```js | ||
// In the real world, this function would probably contain | ||
// a dynamic import of the required translation document | ||
const getDocument = () => ({ | ||
@@ -59,3 +61,3 @@ "hello": "Hello, World!" | ||
### Use a translator function | ||
### Use the translator function | ||
@@ -66,8 +68,36 @@ ```js | ||
## Plugins | ||
This is by far the main strength of the library. | ||
Translating keys relies on simple key-value lookup, and most libraries | ||
add many unnecessary features on top of this primitive functionality. | ||
`intl-schematic` instead provides a way to extend both its functionality and type definitions in a comprehensive enough way, | ||
so that anyone can pick and choose what exact features are needed for their project without any bloat whatsoever. | ||
In other words, plugins allow to almost infinitely expand the functionality of `intl-schematic`. | ||
To find out more, see the main [plugins readme](/packages/plugins/). | ||
### List | ||
Current list of all official plugins is as follows: | ||
- [`@intl-schematic/plugin-defaults`](/packages/plugins/defaults/) | ||
- recommended collection of plugins that should be useful to most applications | ||
- [`@intl-schematic/plugin-arrays`](/packages/plugins/arrays/) (included in **defaults**) | ||
- use arrays to cross-reference keys and define complex multiline texts | ||
- [`@intl-schematic/plugin-functions`](/packages/plugins/functions/) | ||
- use plain functions directly in translation documents with type-checked parameters | ||
- [`@intl-schematic/plugin-locale`](/packages/plugins/locale/) (included in **defaults**) | ||
- provider plugin, allows other plugins to use the provided `Intl.Locale` instance | ||
- [`@intl-schematic/plugin-nested`](/packages/plugins/nested/) | ||
- access nested keys in deep multi-level objects | ||
- [`@intl-schematic/plugin-processors`](/packages/plugins/processors/) (included in **defaults**) | ||
- apply custom and default processors to format the user inputs | ||
### Add default plugins and processors | ||
Plugins allow to infinitely expand the functionality of `intl-schematic`. To find out more, see the main [plugins readme](../plugins/). | ||
You might want to install [the default plugin collection](/packages/plugins/defaults/): | ||
You might want to install [the default plugin collection](../plugins/defaults/): | ||
`npm i @intl-schematic/plugin-defaults` | ||
@@ -74,0 +104,0 @@ |
@@ -33,4 +33,4 @@ import type { LocaleKey } from './'; | ||
export interface PluginRegistry< | ||
Locale extends Record<string, any> = Record<string, any>, | ||
Key extends LocaleKey<Locale> = LocaleKey<Locale>, | ||
LocaleDoc extends Record<string, any> = Record<string, any>, | ||
Key extends LocaleKey<LocaleDoc> = LocaleKey<LocaleDoc>, | ||
PluginInfo = unknown, | ||
@@ -37,0 +37,0 @@ ContextualPlugins extends Record<keyof PluginRegistry, Plugin> = Record<string, Plugin> |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36106
132
0