Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

loco-api-js

standard-readme compliant latest-release license npm-latest size-cjs size-es

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.

Table of Contents

Install

npm i loco-api-js
yarn add loco-api-js

Usage

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'],
  }));
})();

API

LocoClient

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

Client.exportToFile, Client.exportArchive

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

Maintainers

@thibmaek

Contributing

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT Β© 2019 - current Thibault Maekelbergh