papago-sdk
v0.2.1
Published
Papago SDK for Node.js
Downloads
7
Maintainers
Readme
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
- ~~Zero-cost Papago API is available HERE,
text.translate()
anddetect()
is supported only.~~ (working on integration) - 100,000 KRW(~$75) worth credit for Naver Cloud Console is available HERE.
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
, whenfrom
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.