tada5hi / ilingo

Ilingo is a lightweight library for translation and internationalization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ilingo πŸ“š

A lightweight library for translation and internationalization.

Table of Contents

Usage

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.

Packages

The repository contains the following packages:

Core πŸ’¬

ilingo

This package contains the base library for translation and internationalization

Documentation

FS πŸ—ƒοΈ

@ilingo/fs

This package contains a file-system store for the ilingo package.

Documentation

Vue πŸ–ŒοΈ

@ilingo/vue

This package contains an adapter for vue.

Documentation

Vuelidate πŸŽ‰

@ilingo/vuelidate

This package contains an adapter for the vuelidate library.

Documentation

License

Made with πŸ’š

Published under MIT License.

About

Ilingo is a lightweight library for translation and internationalization.

License:MIT License


Languages

Language:TypeScript 78.0%Language:JavaScript 14.0%Language:Vue 6.2%Language:HTML 1.6%Language:Shell 0.1%