Language Translator V3

The IBM Watson Language Translator service lets you select a domain, customize it, then identify or select the language of text, and then translate the text from one supported language to another.

The following example demonstrates how to use the Language Translator service:

import LanguageTranslatorV3

let authenticator = WatsonIAMAuthenticator(apiKey: "{apikey}")
let languageTranslator = LanguageTranslator(version: "2018-05-01", authenticator: authenticator)
languageTranslator.serviceURL = "{url}"

languageTranslator.translate(text: ["Hello"], modelID: "en-es") {
  response, error in

  guard let translation = response?.result else {
    print(error?.localizedDescription ?? "unknown error")
    return
  }

  print(translation)
}

For details on all API operations, including Swift examples, see the API reference.