0.0.42 • Published 5 months ago

minimal-intl v0.0.42

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Minimal Intl

Minmal Intl is meant to be the simplest possible, typesafe solution to add support for multiple languages to your typescript application. It is not meant to be a feature complete localization library and won't replace current major libraries.

Installation

npm install minimal-intl

Usage

In a file, e.g. in your lib/intl/index.ts, initialize your intl utility. Provide keys for all your translation files as well as the default locale.

import { initIntl } from "minimal-intl";
import de from "./de.json";
import en from "./en.json";

export const intl = initIntl({ en, de }, "en");

A locale file should be a normal json file and can contain nested keys.

{
    "option": "an option",
    "nested": {
        "key": "nested key with {{placeholder}}",
    }
}

You can then use the intl object anywhere in your application.

// ...
<span>
    Some Test {intl.get("nested.key", { placeholder: 123 })} Text
</span>
// ...
0.0.42

5 months ago

0.0.41

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.22

5 months ago

0.0.21

5 months ago

0.0.2

5 months ago

0.0.12

5 months ago

0.0.11

5 months ago

0.0.1

5 months ago