🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

minimal-intl

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimal-intl

Minimal, simple, typesafe react intl package

latest
Source
npmnpm
Version
0.0.42
Version published
Maintainers
1
Created
Source

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>
// ...

Keywords

intl

FAQs

Package last updated on 02 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts