Simple NodeJS wrapper around Lokalise service.
Localise API documentation can be found here
Detail package documentation can be found here
- Install
- Usage
- API
- Development
- License
- Support
Install package as yet another npm library with command:
npm install node-lokalise-api
Also you can use another package manager, for example yarn:
yarn add node-lokalise-api
Include in your module:
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({
token: '<your-lokalise-api-token>'
});
// get comments for your project
const result = await api.comments.list('<project id>', null, {page: 1, limit: 100});
Avaiable options are:
token
- access token for Lokalizetimeout
- maximum allowed time for request in millieconds. (10000 by default)retry
- number of allowed retry attempts for failed requests. (2 by default)baseUrl
- base url for Lokalize API endpoints. By default it is https://api.lokalise.co/api2.
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.comments.list('<project id>', null, {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.comments.list('<project id>', '<key id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.comments.create('<project id>', '<key id>', {
comments: [
{comment: 'This is a test.'},
{comment: 'Adding multiple comments.'}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.comments.get('<project id>', '<key id>', '<comment id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.comments.delete('<project id>', '<key id>', '<comment id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.contributors.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.contributors.create('<project id>', {
contributors: [
{
email: '[email protected]',
fullname: 'Mr. Translator',
is_admin: false,
is_reviewer: true,
languages: [
{
lang_iso: en,
is_writable: false
},
{
lang_iso: ru,
is_writable: true
}
],
admin_rights: [
'keys', 'languages'
]
}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.contributors.get('<project id>', '<contributor id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.contributors.update('<project id>', '<contributor id>', {
is_admin: true
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.contributors.delete('<project id>', '<contributor id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.files.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.files.upload('<project id>', {
filename: 'index.json',
data: 'D94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGL.....',
lang_iso: 'en',
tags: [
'index', 'admin', 'v2.0'
],
convert_placeholders: true
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.files.download('<project id>', {
format: 'json',
original_filenames: true
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.create('<project id>', {
keys: [
{
key_name: 'index.welcome',
description: 'Index app welcome',
platforms: ['web'],
translations: [
{
language_iso: 'en',
translation: 'Welcome'
}
]
}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.get('<project id>', '<key id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.update('<project id>', '<key id>', {
platforms: ['web', 'other'],
description: 'Index app welcome'
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.updateMany('<project id>', {
keys: [
{
key_id: 331223,
key_name: 'index.welcome',
description: 'Index app welcome',
platforms: ['web']
},
{
key_id: 331224,
key_name: 'index.hello',
description: 'Index greetings',
platforms: ['web']
}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.deleteMany('<project id>', {
keys: [12345, 12346]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.keys.delete('<project id>', '<key id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.list(null, {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.create('<project id>', {
languages: [
{lang_iso: 'en'},
{lang_iso: 'ru'}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.get('<project id>', '<language id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.update('<project id>', '<language id>', {
lang_iso: 'en-US',
plural_forms: [
'one', 'zero', 'few', 'other'
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.languages.delete('<project id>', '<language id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.list({page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.create({
name: 'TheApp Project',
description: 'iOS + Android strings of TheApp. https://theapp.com'
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.get('<project id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.update('<project id>', {
name: 'TheZapp Project',
description: 'iOS + Android strings of TheZapp. https://thezapp.com'
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.empty('<project id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.projects.delete('<project id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.screenshots.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.screenshots.create('<project id>', {
screenshots: [
{
data: 'data:image/jpeg;base64,D94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGL',
ocr: false,
key_ids: [
1132290, 1132292, 1132293
],
tags: [
'onboarding'
]
}
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.screenshots.get('<project id>', '<screenshot id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.screenshots.update('<project id>', '<screenshot id>', {
key_ids: [
1132290, 1132292
],
tags: [
'main'
]
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.screenshots.delete('abcde.12345', 567);
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.snapshots.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.snapshots.create('<project id>', {
title: 'API snapshot'
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.snapshots.restore('<project id>', '<snapshot id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.snapshots.delete('<project id>', '<snapshot id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.tasks.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.tasks.create('<project id>', {
title: 'Voicemail messages',
description: 'Need your help with some voicemail message translation. Thanks!',
due_date: '2018-12-31 12:00:00 (Etc\/UTC)',
keys: [11212, 11241, 11245],
languages: [
{
language_iso: 'fi',
users: [421]
},
{
language_iso: 'ru',
users: [422]
}
],
auto_close_languages: true,
auto_close_task: true
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.tasks.get('<project id>', '<task id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.tasks.update('<project id>', '<task id>', {
due_date: '2019-12-31 12:00:00 (Etc\/UTC)',
auto_close_languages: false,
auto_close_task: false
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.tasks.delete('<project id>', '<task id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.teamUsers.list('<team id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.teamUsers.get('<team id>', '<user id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.teamUsers.update('<team id>', '<user id>', {
role: 'admin'
});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.teamUsers.delete('<team id>', '<user id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.teams.list({page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.translations.list('<project id>', {page: 1, limit: 100});
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.translations.get('<project id>', '<translation id>');
const {LokaliseAPI} = require('node-lokalise-api');
const api = new LokaliseAPI({token: '<your-lokalise-api-token>'});
const result = await api.translations.update('<project id>', '<translation id>', {
translation: 'Quick brown fox jumps over the lazy dog.',
is_fuzzy: false,
is_reviewed: true
});
Clone repository or its fork to local filesystem
git clone https://github.com/tormozz48/node-lokalise-api.git
Install npm dependencies:
npm install
Here are some suitable commands that can be used during development:
npm run build
- compile typescript filesnpm run docs
- create documentation based on jsdocsnpm run lint
- run tslint verification toolnpm run test
- run tests with mochanpm run cover
- calculate code test coverage with istanbulnpm run watch
- launch watcher for compile source files during development
Apache-2.0
Bugs, PRs, comments, suggestions welcomed!