New languages for Amazon Translate: Greek, Hungarian, Romanian, Thai, Ukrainian, Urdu and Vietnamese

Technical Evangelists travel quite a lot, and the number one question that we get from customers when presenting Amazon Translate is: “Is my native language supported?“. Well, I’m happy to announce that starting today, we’ll be able to answer “yes” if your language is Greek, Hungarian, Romanian, Thai, Ukrainian, Urdu and Vietnamese. In fact, using Amazon Translate, we could even say “ναί”, “igen”, “da”, “ใช่”, “так”, “جی ہاں” and “có”… hopefully with a decent accent!

With these additions, Amazon Translate now supports 32 languages: Arabic, Chinese (Simplified), Chinese (Traditional), Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian, Urdu and Vietnamese.

Between these languages, the service supports 987 translation combinations: you can see the full list of supported language pairs on this documentation page.

Using Amazon Translate
Amazon Translate is extremely simple to use. Let’s quickly test it in the AWS console on one of my favourite poems:

Developers will certainly prefer to invoke the TranslateText API. Here’s an example with the AWS CLI.

$ aws translate translate-text --source-language-code auto --target-language-code hu --text "Les sanglots longs des violons de l’automne blessent mon coeur d’une langueur monotone"
{
"TranslatedText": "Az őszi hegedű hosszú zokogása monoton bágyadtsággal fáj a szívem",
"SourceLanguageCode": "fr",
"TargetLanguageCode": "hu"
}

Of course, this API is also available in any of the AWS SDKs. In the continued spirit of language diversity, how about an example in C++? Here’s a short program translating a text file stored on disk.

#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 

# define MAX_LINE_LENGTH 5000

int main(int argc, char **argv) {
  if (argc != 4) {
    std::cout << "Usage: translate_text_file 'target language code' 'input file' 'output file'"
         << std::endl;
    return -1;
  }

  const Aws::String target_language = argv[1];
  const std::string input_file = argv[2];
  const std::string output_file = argv[3];

  std::ifstream fin(input_file.c_str(), std::ios::in);
  if (!fin.good()) {
    std::cerr << "Input file is invalid." << std::endl;
    return -1;
  }

  std::ofstream fout(output_file.c_str(), std::ios::out);
  if (!fout.good()) {
    std::cerr << "Output file is invalid." << std::endl;
    return -1;
  }

  Aws::SDKOptions options;
  Aws::InitAPI(options);
  {
    Aws::Translate::TranslateClient translate_client;
    Aws::Translate::Model::TranslateTextRequest request;
    request = request.WithSourceLanguageCode("auto").WithTargetLanguageCode(target_language);

    Aws::String line;
    while (getline(fin, line)) {
      if (line.empty()) {
        continue;
      }

      if (line.length() > MAX_LINE_LENGTH) {
        std::cerr << "Line is too long." << std::endl;
        break;
      }

      request.SetText(line);
      auto outcome = translate_client.TranslateText(request);

      if (outcome.IsSuccess()) {
        auto translation = outcome.GetResult().GetTranslatedText();
        fout << translation << std::endl;
      } else {
        std::cout << "TranslateText error: " << outcome.GetError().GetExceptionName()
             << " - " << outcome.GetError().GetMessage() << std::endl;
        break;
      }
    }
  }
  Aws::ShutdownAPI(options);
}

Once the code has been built, let’s translate the full poem to Thai:

$ translate_text_file th verlaine.txt verlaine-th.txt

$ cat verlaine-th.txt

“เสียงสะอื้นยาวของไวโอลินฤดูใบไม้ร่วงทำร้ายหัวใจของฉันด้วยความอ่อนเพลียที่น่าเบื่อ ทั้งหมดหายใจไม่ออกและซีดเมื่อชั่วโมงดังผมจำได้ว่าวันเก่าและร้องไห้ และฉันไปที่ลมเลวร้ายที่พาฉันออกไปจากที่นี่ไกลกว่าเช่นใบไม้ที่ตายแล้ว” - Paul Verlaine บทกวีของดาวเสาร์

As you can see, it’s extremely simple to integrate Amazon Translate in your own applications. An single API call is really all that it takes!

Available Now!
These new languages are available today in all regions where Amazon Translate is available. The free tier offers 2 million characters per month for the first 12 months, starting from your first translation request.

We’re looking forward to your feedback! Please post it to the AWS Forum for Amazon Translate, or send it to your usual AWS support contacts.

Julien;