Code Monkey home page Code Monkey logo

loco-api-js's Introduction

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

loco-api-js's People

Contributors

robrechtme avatar thibmaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.