0.1.1 • Published 5 months ago

papago-sdk-js v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Papago Translation API SDK

SDK for Papago Translation API, supports multiple languages.

Prerequisites

This SDK requires Papago API Client ID and Secret.

For further guidance, see Client ID and Secret.

Note

Installation

pnpm add papago-sdk-js

Usage

Papago

Set up a client with your Papago Translation credentials.

// CJS
const { Papago } = require('papago-sdk-js')

// ESM
import { Papago } from 'papago-sdk-js'

const papago = new Papago({
  id: 'PAPAGO_CLIENT_ID',
  secret: 'PAPAGO_CLIENT_SECRET',
})

translate({ type: 'text' })

Translate the given text from one language to another.

const textTranslation = await papago.translate({
  from: 'en',
  to: 'ko',
  type: 'text',
  input: 'Hello, World!'
});

// Output:
{
  message: {
    result: {
      srcLangType: 'en',
      tarLangType: 'ko',
      translatedText: '안녕, 세상!'
    }
  }
}

textOnly: Boolean

Returns translated text only as translatedText.

const textOnly = await papago.translate({
  from: 'en',
  to: 'ko',
  type: 'text',
  text: 'Hello, World!',
  textOnly: true,
})

// Output:
{
  translatedText: '안녕, 세상!'
}

translate({ type: 'html' })

Translate an HTML string from one language to another as translatedHtml.

Note that the HTML structure will be preserved.

const htmlTranslation = await papago.translate({
  from: 'en',
  to: 'ko',
  type: 'html',
  input: '<div>Hello, world!</div>',
})

// Output:
{
  translatedHtml: '<div>안녕, 세상!</div>'
}

Good to know: For translate, when from is set to 'auto', the source language is detected automatically.

detect

Detect lang code of the given text.

const detection = await papago.detect({
  query: 'Hello World!',
})

// Output:
{
  langCode: 'en'
}

Language Support

Order by Accuracy & Cross-Language Support

  • 🇰🇷 한국어
  • 🇺🇸 English
  • 🇯🇵 日本語
  • 🇨🇳 简体中文
  • 🇹🇼 繁體中文
  • 🇻🇳 Tiếng Việt
  • 🇹🇭 ภาษาไทย
  • 🇮🇩 Indonésia
  • 🇫🇷 français
  • 🇪🇸 español
  • 🇷🇺 русский
  • 🇩🇪 Deutsch
  • 🇮🇹 italiàno

For more information, see Language Support.

Disclaimer

papago-sdk is an open source published by an individual.

The activities and announcements of papago-sdk are not affiliated with Naver Cloud, corp.

0.1.1

5 months ago

0.1.0

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago

0.0.0

9 months ago