ez-vanjs-i18n
v0.0.3
Published
A simple i18n library for vanjs
Downloads
11
Readme
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.