LoginSignup
2
1

More than 5 years have passed since last update.

Azure の Translator Text API で翻訳できる言語を調べた

Last updated at Posted at 2017-11-14

概要

翻訳サービスで利用できる言語は60 (*1) という情報があるが、パラメータで指定する言語キーの一覧を取得してみた。

*1 https://www.microsoft.com/en-us/translator/languages.aspx

実装

ポイント

'use strict';

var https = require('https');

getLanguagesForTranslate(function (token) {
    getLanguagesForTranslate(lang, function (translated) {
        // 言語をログ出力
       console.log('LangsForTranslate : ' + lang);
    });
});


// 利用可能な言語キーを取得する
function getLanguagesForTranslate(token, callback) {

    const subscriptionKey = "アクセスキーを指定してください";
    var body = '';
    var options = {
        host: 'api.microsofttranslator.com',
        path: '/V2/Http.svc/GetLanguagesForTranslate',
        method: 'GET' ,  
        headers: {
              'Ocp-Apim-Subscription-Key': subscriptionKey
       }
    };

    var req = https.request(options, function (res) {
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            body += chunk;
        }).on('end', function () {
        });
    }).on('error', function (err) {
        console.log(err);
    });


    req.end();

}

結果:利用可能な言語キー

  • af
  • ar
  • bn
  • bs-Latn
  • bg
  • ca
  • zh-CHS
  • zh-CHT
  • yue
  • hr
  • cs
  • da
  • nl
  • en
  • et
  • fj
  • fil
  • fi
  • fr
  • de
  • el
  • ht
  • he
  • hi
  • mww
  • hu
  • id
  • it
  • ja
  • sw
  • tlh
  • tlh-Qaak
  • ko
  • lv
  • lt
  • mg
  • ms
  • mt
  • yua
  • no
  • otq
  • fa
  • pl
  • pt
  • ro
  • ru
  • sm
  • sr-Cyrl
  • sr-Latn
  • sk
  • sl
  • es
  • sv
  • ty
  • ta
  • th
  • to
  • tr
  • uk
  • ur
  • vi
  • cy
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1