A lightweight library for translation and internationalization.
Table of Contents
Create an instance and set the default locale.
import { Ilingo } from 'ilingo';
const ilingo = new Ilingo({
locale: 'en'
})
The default (memory-) store can be initialized with some default data.
import { Ilingo, MemoryStore } from 'ilingo';
const store = new MemoryStore({
data: {
// locale: de
de: {
// group: app
app: {
key: 'Hallo mein Name ist {{name}}'
}
},
// locale: en
en: {
app: {
key: 'Hello my name is {{name}}'
}
},
}
});
const ilingo = new Ilingo({
store,
locale: 'en'
});
To retrieve text from any of the language files, simply pass the filename/group and the access key as the first parameter, separated by a period (.).
After that you can simply access the locale string, as described in the following:
import { Ilingo } from 'ilingo';
const ilingo = new Ilingo({
// ...
});
await ilingo.get({
group: 'app',
key: 'key'
});
// Hello my name is {{name}}
await ilingo.get({
group: 'app',
key: 'key',
data: {
name: 'Peter'
}
});
// Hello my name is Peter
await ilingo.get({
group: 'app',
key: 'key',
data: {
name: 'Peter'
},
locale: 'de'
});
// Hallo mein Name ist Peter
To learn more about usage, inspect the README.md of the core package.
The repository contains the following packages:
ilingo
This package contains the base library for translation and internationalization
@ilingo/fs
This package contains a file-system store for the ilingo package.
@ilingo/vue
This package contains an adapter for vue.
@ilingo/vuelidate
This package contains an adapter for the vuelidate library.
Made with 💚
Published under MIT License.