Created: 2011-07-11 15:17
Updated: 2013-10-10 17:43


Scala-translate-API is a very simple API for some of the online translation APIs such as Bing Translate API or Google Translate. So far, given that the future of Google Translate is unclear, only the Bing Translate API is supported.

The API is currently fully synchronous, but using the asynchronous capabilities of the Dispatch library is one of the TODO items for future releases. For the time being, please encapsulate the API calls within a simple actor to obtain asynchronous capabilities.

Bing API Usage

The Bing API implementation is currently based on the HTTP version of the Microsoft Translator V2 as described here: Only the Microsoft.Translator.Translate method ( is supported.

Please note that Bing requires its own application id in order to use the translation API.

API usage:

val translator = new Translate with Bing with new BingConfig {
	val appId = "your-bing-app-id-goes-here"
val result = translator.translate("text to translate", English, Spanish)

Translation results are returned as an Either object, where Left indicates an error, wrapped in a TranslationFailure object and Right indicates success, wrapped in a TranslationResult object. Therefore, results can be processed as follows:

result match {
  case Left(TranslationFailure(_, message, _)) => println("There was an error: " + message)
  case Right(TranslationResult(text)) => println("translation result: " + text)

Project setup

The library is cross-compiled for Scala 2.9.0 and 2.9.0-1, and can be declared as a dependency in your project with SBT or Maven.

Using SBT:

val renalias_repo = " Maven Repository" at ""
val translate_lib = "net.renalias" %% "scala-translate-api" % "1.0-SNAPSHOT"

Using Maven, first declare the repository:

  <name> Repository</name>

And then declare the dependency:

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more