UNPKG

language-cloud-js-sdk

Version:

Language Cloud javascript sdk

93 lines (67 loc) 2.26 kB
<img src="https://www.rws.com/media/images/logo-rws_tcm228-236815.svg?v=20250605090631" alt="drawing" width="200"/> # Language Cloud SDK Client implementation for Language Cloud Public API. ## Installation Install language-cloud-js-sdk via [npm](https://npmjs.org/) ```bash npm install language-cloud-js-sdk ``` ## Usage/Examples LC Instance Creation ```bash 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 ```bash const response = await client.projectService.getProjects(); ``` Create a new project ```bash 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 ```bash 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 ```bash const response = await client.projectService.startProject('YOUR_PROJECT_ID'); ``` Get project details ```bash const response = await client.projectService.getProject('YOUR_PROJECT_ID'); ``` ## External Resources [RWS Language Cloud API Documentation](https://eu.cloud.trados.com/lc/api-docs/introduction) ## TypeScript This SDK comes with TypeScript "typings". If you happen to find any bugs in those, create an issue. ## Dependencies - [axios](https://www.npmjs.com/package/axios)