npm.io
1.0.16 • Published 1 year ago

localisr

Licence
MIT
Version
1.0.16
Deps
0
Vulns
0
Weekly
0

Localisr - Manage language translations at the click of a button

Localisr exists to make a developer's life a bit easier when developing multi-language websites and apps.

Website • Create account

npm version install size npm downloads

Installing

Using npm:

$ npm install localisr

Using yarn:

$ yarn add localisr

Once the package is installed, you can import the library using import or require approach:

import {LocalisrClient} from 'localisr'

or

const {LocalisrClient} = require('localisr')

Example

This shows the method for getting translations of all the keys within a group.

import {LocalisrClient} from 'localisr'

// initialize Localisr client
const localisr = new LocalisrClient(
    <LOCALISR_ACCESS_TOKEN>, 
    <LOCALISR_PROJECT_KEY>
);

// get translations for all the keys in 'user-login' group
const translations = await localisr
    .setLanguage(<language>)
    .groups()
    .getTranslations(<group-name>)
    .catch((error) => {
        console.log(error.response)
    });

Get all added documents

// initialize Localisr client
const localisr = new LocalisrClient(
    <LOCALISR_ACCESS_TOKEN>, 
    <LOCALISR_PROJECT_KEY>
);

// get translations for all the keys in 'user-login' group
const documents = await localisr
    .documents()
    .getAll()
    .catch((error) => {
        console.log(error.response)
    });

Keywords