1.0.2 • Published 3 years ago

transpoco-translation-library-js v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Transpoco Translation Library js

Transpoco translation library for Node JS / Javascript to handle translations returned from Transpoco Translation API.

Usage

First it's necessary to load the translation table, for example:

import Translation from '@transpoco/transpoco-translation-library-js';
// Example of a translation table returned from API
const translationTable = [
    {
        id: 14,
        code: 'Original',
        string: 'Original',
    }, {
        id: 15,
        code: 'Translation',
        string: 'Traduction',
    }, {
        id: 16,
        code: 'More information...',
        string: 'Plus d\'informations',
    },
    {
        id: 17,
        code: 'Good morning {name}',
        string: 'Bonjour {name}',
    },
    {
        id: 17,
        code: 'Hello {name} and {name2}',
        string: 'Bonjour {name} et {name2}',
    },
];

// Set Translation to french
const t = new Translation();
t.importTranslationTable(translationTable);

The library comes with the _ funtion to translate words and supports interpolation:

t._('Translation'); // Traduction
t._('Good morning {name}', {name: 'John'}); // Bonjour John

Development

All tests are handle by Mocha and Chai, the entry file it's Translation.js, the project uses Babel to transpile ES6 to ES5.

Publish to NPM

npm version patch -m 'Update reason'
npm publish
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago