Git Product home page Git Product logo

papago-sdk-js's Introduction

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

Usage

Papago

Set up a client with your Papago Translation credentials.

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

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

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.

papago-sdk-js's People

Contributors

dependabot[bot] avatar devjiwonchoi avatar

Watchers

 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.