Languages API

Get Source Language

The first step to getting your translation is to identify the source language of the document that needs to be translated and verifying whether Translate By Humans currently supports translation from your desired source language.

The sourcelanguage API returns a JSON array with the complete list of languages that Translate By Humans supports. For each language, the returned data contains -

  1. ID : unique ID of the language
  2. code : shorthand representation for the language. E.g., “en” for English
  3. name: the name of the language

Use the following API for requesting source language:


Request Method  : GET 
ContentType : application/x-www-form-urlencoded
Request Url : API_BASE_URL/API_VERSION/sourcelanguage/
Auth : Yes

Here’s a PHP SDK for Get Source Language:


require_once 'tbh-sdk/TbhClient.php';
$apiclient = new TbhClient(CLIENT_ID,CLIENT_SECRET,CLIENT_PUBLIC,ACCESS_TOKEN);
$source_data = $apiclient->GetSourceLanguage();

Look at the sample output example given below:


{
  "data": [
    {
      "id": "442",
      "code": "af",
      "name": "Afrikaans"
    },
    {
      "id": "443",
      "code": "sq",
      "name": "Albanian"
    },
    {
      "id": "444",
      "code": "ar",
      "name": "Arabic"
    },
.
.
.
 {
      "id": "518",
      "code": "cy",
      "name": "Welsh"
    }
  ],
  "message": "Success",
  "error_code": 0,
  "success": true
}

Get Destination Language

Once you have identified the source language from the list of available language options from sourcelanguage, the next step is to set the “Destination Language”, i.e. the language to which the translation is desired.

The destinationlanguage API returns a list of languages that are available for translation from the source language you’ve chosen. Remember that you must have the source language before you can call this API.

Use the following API for requesting destination language:


Request Method  : Get 
ContentType : application/x-www-form-urlencoded
Requets Url : API_BASE_URL/API_VERSION/destinationlanguage/SOURCE_LANGUAGE
Auth : Yes

Replace “SOURCE_LANGUAGE” with the code for the source language you got using sourcelanguage api in step one. E.g., use “en” if your source language is English.

The final URL will look like this: www.api.example.com/v1/destinationlanguage/en

Here’s a PHP SDK for Get Destination Language:


require_once 'tbh-sdk/TbhClient.php';
$apiclient = new TbhClient(CLIENT_ID,CLIENT_SECRET,CLIENT_PUBLIC,ACCESS_TOKEN);
$lang_code = ‘en’;
$source_data = $apiclient->GetDestinationLanguage($lang_code);

The output for the above code will look like this:


{
  "data": [
    {
      "source_language_id": "456",
      "destination_language_id": "442",
      "destination_language_name": "Afrikaans",
      "destination_language_code": "af"
    },
    {
      "source_language_id": "456",
      "destination_language_id": "507",
      "destination_language_name": "Thai",
      "destination_language_code": "th"
    },
    {
      "source_language_id": "456",
      "destination_language_id": "479",
      "destination_language_name": "Lithuanian",
      "destination_language_code": "lt"
    },
    {
      "source_language_id": "456",
      "destination_language_id": "453",
      "destination_language_name": "Danish",
      "destination_language_code": "da"
    },
.
.
.
 {
      "source_language_id": "456",
      "destination_language_id": "500",
      "destination_language_name": "Spanish-Latin America ",
      "destination_language_code": "es_LA"
    }
  ],
  "message": "Success",
  "error_code": 0,
  "success": true
}
© 2019 Translate By Humans [Innovative Humans Limited]. All Rights Reserved.