ez-vanjs-i18n

0.0.3 • Public • Published

Ez Vanjs i18n

Ez Vanjs i18n is a simple and easy to use internationalization library for VanJs.

Installation

npm install ez-vanjs-i18n

Usage

Import the I18n class

import { I18n } from 'ez-vanjs-i18n';

Define a translation map

const translations = new Map([
    ['en', {
        hello: 'Hello',
        nested: {
            world: 'World'
        },
        greeting: (params) => `Hello ${params.name}`
    }],
    ['fr', {
        hello: 'Bonjour',
        nested: {
            world: 'Monde'
        },
        greeting: (params) => `Bonjour ${params.name}`
    }]
]);

Create an instance of the I18n class

const i18n = new I18n(translations, 'en');

Create a stateful translation variable

const greeting = i18n.t('greeting', { name: 'John' });

Example

A full example of how to use Ez Vanjs i18n can be found in the example directory.

Readme

Keywords

Package Sidebar

Install

npm i ez-vanjs-i18n

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

5.81 kB

Total Files

6

Last publish

Collaborators

  • rcharre