0.0.3 • Published 1 year ago

ez-vanjs-i18n v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.

0.0.3

1 year ago

0.0.3-SNAPSHOT

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago