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!`
I've grown frustrated with current implementations of popular l10n/i18n libraries, many of which:
Intl
),This library will try to avoid these common pitfalls, while retaining a small size and good performance.
Even though custom plugins can do literally anything with keys, values and translation documents,\ the core library will not support:
nested
plugin (which supports dot-notation!);To contribute, create a branch and make a PR to main
, or create an issue.
This project utilizes a monorepo structure based on npm workspaces,\
with the main package being, of course, intl-schematic
.
Full list of packages at the moment:
intl-schematic
- main package
@intl-schematic/cli
- cli package, used for automating different manual work when setting up the library
@intl-schematic/solid
- reactive adapter for solid-js
@intl-schematic/vue
(WIP) - reactive adapter for vue
@intl-schematic/react
(WIP) - reactive adapter for react
Plugins - allow using custom formats in translation documents - not just strings:
@intl-schematic/plugin-defaults
@intl-schematic/plugin-arrays
(included in defaults) - includes a JSON-schema@intl-schematic/plugin-functions
@intl-schematic/plugin-locale
(included in defaults)Intl.Locale
instance@intl-schematic/plugin-nested
- includes a JSON-schema@intl-schematic/plugin-processors
(included in defaults) - includes a JSON-schematsconfig
- typescript config used by the packages
To develop locally, simply clone, and run the following in the root directory:
npm i -ws
The project uses TypeScript v5.3+
Simply run
npm run build
to rebuild any changed packages.
In order to evaluate and test the newest version that is yet to be released on npm, simply install from github:
npm install 'https://gitpkg.now.sh/Raiondesu/intl-schematic/packages/core?main'
β Nightly builds are unstable and may be broken β