Lokalise APIv2 Node SDK

Node interface for the Lokalise APIv2.

View the Project on GitHub lokalise/node-lokalise-api




Translation files

File attributes

Fetch translation files

API doc

const files = await lokaliseApi.files().list({
  project_id: project_id,
  page: 3,
  limit: 4
});

files.items[0].filename;

Download translation files

API doc

Exports project files as a .zip bundle and makes them available to download (the link is valid for 12 months).

const response = await lokaliseApi.files().download(project_id,
  {format: 'json', "original_filenames": true}
);

response.bundle_url;

Upload translation file

API doc

Background uploading is the only method of importing files since July 2020.

process = await lokaliseApi.files().upload(project_id,
  {data: data_base64, filename: 'test1.json', lang_iso: 'en'}
);
process.status; // => 'queued'

Asynchronous upload will return a QueuedProcess containing process ID, status of the process (queued, finished, failed etc) and some other info. You may periodically check the status of the process by using get() method:

process = await lokaliseApi.files().upload(project_id,
  {data: data_base64, filename: 'test1.json', lang_iso: 'en'}
);

// You'll obtain `process_id` after calling `files.upload()`
process = await lokaliseApi.queuedProcesses().get(process.process_id, { project_id: project_id })

process.status // => 'finished'

Delete translation file

API doc

Please note that this endpoint does not support “software localization” projects.

const response = await lokaliseApi.files().delete(file_id,
  { project_id: project_id }
);

response.project_id // => "123.abc"
response.file_deleted // => true