1.0.6 • Published 6 months ago

language-cloud-js-sdk v1.0.6

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 months ago

Language Cloud SDK

Client implementation for Language Cloud Public API.

Installation

Install language-cloud-js-sdk via npm

  npm install language-cloud-js-sdk

Usage/Examples

LC Instance Creation

import { createLanguageCloudClient } from 'language-cloud-js-sdk';

const client = await createLanguageCloudClient('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_ACCOUNT_ID');

Get all projects via the projectService

const response = await client.projectService.getProjects();

Create a new project

const response = await client.projectService.createProject({
  name: 'YOUR_PROJECT_NAME',
  dueBy: 'YYYY-MM-DDThh:mmZ',
  projectTemplate: {
    id: 'YOUR_PROJECT_TEMPLATE_ID',
  },
  languageDirections: [
    {
      sourceLanguage: {
        languageCode: 'YOUR_SOURCE_LANGUAGE_CODE',
      },
      targetLanguage: {
        languageCode: 'YOUR_TARGET_LANGUAGE_CODE',
      },
    }],
    location: 'YOUR_LOCATION_ID',
  });

Attach a source file to the project via the sourceFileService

const fileBuffer = Buffer.from(FILE_CONTENT, 'utf-8');
const formData = new FormData();
  formData.append('properties',
    JSON.stringify({
      name: 'YOUR_FILE_NAME',
      role: 'translatable',
      type: 'native',
      language: 'en-US',
    })
  );
formData.append('file', fileBuffer, { filename: 'YOUR_FILE_NAME', contentType: 'FILE_TYPE' });
const response = await client.sourceFileService.addSourceFile('YOUR_PROJECT_ID', formData);

Start the project

const response = await client.projectService.startProject('YOUR_PROJECT_ID');

Get project details

const response = await client.projectService.getProject('YOUR_PROJECT_ID');

External Resources

RWS Language Cloud API Documentation

TypeScript

This SDK comes with TypeScript "typings". If you happen to find any bugs in those, create an issue.

Dependencies

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

7 months ago