Javascript API wrapper for Loco translation system's REST API
Convenience API wrapper around the Loco REST API, written in modern Javascript. Modules are provided as CommonJS, UMD and ESM.
npm i loco-api-js
yarn add loco-api-js
See and run example.js or try it out in a REPL
// ESM (Bundlers, Modern engines)
import LocoClient from 'loco-api-js';
// CJS (Node)
const LocoClient = require('loco-api-js');
const loco = new LocoClient('<your-api-key>');
(async () => {
console.log(await loco.getAssets());
console.log(await loco.getAsset('some.asset.path'));
console.log(await loco.getAsset(['some', 'asset', 'path']));
console.log(await loco.getAssetsByTags(['1.5.0']));
console.log(await loco.getTranslation('some.asset.path', 'en'));
console.log(await loco.exportToFile({
tags: ['production'],
withoutTags: ['unused'],
}));
console.log(await loco.exportArchive({
tags: ['production'],
withoutTags: ['unused'],
}));
})();
These options can be provided in an object as a second argument when creating the client to interact with.
Option | Type | Requirement | Description | Default |
---|---|---|---|---|
fileName | string |
Optional | When provided, methods that export a file (JSON/ZIP) will use this name | loco-locales |
debug | boolean |
Optional | Will be more verbose in output and show for example the API req. URL | false |
Provide as an object to the methods that export a file.
Option | Type | Requirement | Description | Default |
---|---|---|---|---|
tags | Array<string> |
Optional | Only assets with these tags will be included | undefined |
withoutTags | Array<string> |
Optional | Assets that carry this tag will not be included | undefined |
PRs accepted.
Small note: If editing the README, please conform to the standard-readme specification.
MIT ยฉ 2019 - current Thibault Maekelbergh