Translation (website translation request)
    • PDF

    Translation (website translation request)

    • PDF

    Article Summary

    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

    NameDescription
    Content-Typeapplication/x-www-form-urlencoded
    X-NCP-APIGW-API-KEY-IDClient ID issued when registering the NAVER Cloud Platform app
    X-NCP-APIGW-API-KEYSecret key issued when registering the NAVER Cloud Platform app

    Parameter

    NameTypeRequiredDescription
    sourceString{ko,ja,en,zh-CN}true- Source language code
    - Automatically detects the source language when set to auto
    targetString{ko,ja,en,zh-CN}trueTarget language code
    htmlStringtrue- 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 NameTypeDescription
    status_codeIntegerUpon receiving a normal response, 200
    dataStringTranslated 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?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.