Translation (website translation request)
- Print
- PDF
Translation (website translation request)
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Overview
- This API translates html documents or elements from the source language into a target language.
- Supported language pairs: Korean↔English, Korean↔Japanese, Korean↔Chinese (Simplified)
- Even if the source language isn’t specified, the API automatically detects the language and provides a translation. In such cases, billing is based only on the number of characters requested for translation; there is no charge for language detection.
Header
Name | Description |
---|---|
Content-Type | application/x-www-form-urlencoded |
X-NCP-APIGW-API-KEY-ID | Client ID issued when registering the NAVER Cloud Platform app |
X-NCP-APIGW-API-KEY | Secret key issued when registering the NAVER Cloud Platform app |
Parameter
Name | Type | Required | Description |
---|---|---|---|
source | String{ko,ja,en,zh-CN} | true | - Source language code - Automatically detects the source language when set to auto |
target | String{ko,ja,en,zh-CN} | true | Target language code |
html | String | true | - Full html document or element to be translated - Requests must be within 200,000 bytes including UTF-8-based tags and spaces |
Response
Return in string format
Field Name | Type | Description |
---|---|---|
status_code | Integer | Upon receiving a normal response, 200 |
data | String | Translated html string |
CURL Example
$ curl --location --request POST 'https://naveropenapi.apigw.ntruss.com/web-trans/v1/translate' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'X-NCP-APIGW-API-KEY-ID: Issued_CLIENT_ID' \
--header 'X-NCP-APIGW-API-KEY: Issued_SECRET_KEY' \
--data-urlencode 'source=ko' \
--data-urlencode 'target=en' \
--data-urlencode 'html=<div>Hello. I’m Papago.</div>'\''
<div papago-id="0" papago-translate="translated"><font class="papago-parent"><font class="papago-source" style="display:none;">
</font>
</font><font class="papago-parent"><font class="papago-source" style="display:none;"> Hello. I’m Papago.</font> Hello, I'\''m Papago.</font><font class="papago-parent"><font class="papago-source" style="display:none;">
</font>
</font></div>%
'
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Example</title>
<style>
body {
margin-top: 50px;
}
ul.comment_container {
width: 500px;
list-style-type: none;
}
li.comment_item_wrapper {
margin-bottom: 5rem;
padding: 10px 20px;
border: 1px solid gray;
border-radius: 10px;
}
.user_info {
font-weight: bold;
}
</style>
</head>
<body>
<!-- comments -->
<ul class="comment_container">
<!-- comment -->
<li class="comment_item_wrapper">
<div class="user_info">
<span class="nickname">user1</span>
</div>
<div class="content">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus
nostrum in earum minus voluptates nobis fugiat rerum totam illum
ipsum.
</p>
</div>
</li>
<!-- comment -->
<!-- comment -->
<li class="comment_item_wrapper">
<div class="user_info">
<span class="nickname">user2</span>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet.</p>
</div>
</li>
<!-- comment -->
<!-- comment -->
<li class="comment_item_wrapper">
<div class="user_info">
<span class="nickname">user3</span>
</div>
<div class="content">
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ex tempora
ipsa iusto temporibus consectetur. Libero sequi consequatur
quibusdam dignissimos totam, praesentium harum dolor nisi
repudiandae in error tempora incidunt aperiam.
</p>
</div>
</li>
<!-- comment -->
<!-- comment -->
<li class="comment_item_wrapper">
<div class="user_info">
<span class="nickname">user4</span>
</div>
<div class="content">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus
nostrum in earum minus voluptates nobis fugiat rerum totam illum
ipsum.
</p>
<br>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</li>
<!-- comment -->
</ul>
<!-- comments -->
<script>
const comments = [
...document.getElementsByClassName('comment_item_wrapper'),
];
const htmlsToRequest = comments.map((comment) => comment.outerHTML);
console.log(htmlsToRequest);
</script>
</body>
</html>
Was this article helpful?