libretranslate
v1.0.1
Published
Simple API wrapper for LibreTranslate
Downloads
89
Readme
LibreTranslate (NPM)
Simple API wrapper for LibreTranslate, an open-source alternative to Google Translate, also supports self-hosted versions
Installation
Node.js v17.5.0 or newer with fetch is required.
# NPM
npm install libretranslate
# Yarn
yarn add libretranslate
Usage
// CommonJS
const { translate } = require('libretranslate');
// ES Modules (ESM) or Typescript
import { translate } from 'libretranslate';
Using translate()
function.
await translate({
query: 'text', // Text to be translated.
source: 'lang', // The original language. (auto by default)
target: 'lang', // The language to translate.
format: 'text', // The format of the translated text (HTML or Text) Optional
apiurl: 'URL', // Custom API url, if self-hosted
apikey: 'key', // API Key
});