@tiny-libs/nls
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@tiny-libs/nls

Tiny internationalization library. Inspired by vscode-nls.

Features

  • No dependencies
  • Crazy fast
  • Support Node.js and browser
  • ESM support

Install

npm i @tiny-libs/nls

Usage

import nls from '@tiny-libs/nls'

const messages = {
  'say.hello': '你好, {0}',
  say: {
    yes: '好的, {0}'
  }
}

const localize = nls.loadMessages(messages)

console.log(localize('hello.world', 'Hello World')) // Output: Hello World
console.log(localize('say.hello', 'Hello, {0}', 'Alex')) // Output: 你好, Alex
console.log(localize('say.yes', 'Yes, {0}', 'Alex')) // Output: 好的, Alex

License

MIT copyright © 2024-present alex wei

Readme

Keywords

Package Sidebar

Install

npm i @tiny-libs/nls

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

7.3 kB

Total Files

8

Last publish

Collaborators

  • alex.wei