TermBase Translation API

The TermBase Translation API is composed of 3 endpoints:

List Term Translations

This endpoint is only accessible by the private Project API key and is used to list translations for a term.

/api/projects/:project_token/terms/:term_id/locales/:locale_code/translations.format [GET]

Where format is one of xml, json or yaml. Note that you can get a JSONP response by adding a ?callback=yourFunctionName parameter to the json API call.

Example response with JSON:

[
  {
    "id": 1234,
    "locale": "fr",
    "text": "Utilisateur",
    "description": "Une personne utilisant WebTranslateIt",
    "status": "approved"
    "created_at": "2010-02-11 21:14:19 UTC",
    "updated_at": "2011-10-09 08:33:18 UTC",
  },
  {
    "id": 1234,
    "locale": "fr",
    "text": "Voiture",
    "description": "Une personne utilisant WebTranslateIt",
    "status": "refused"
    "created_at": "2010-02-11 21:14:19 UTC",
    "updated_at": "2011-10-09 08:33:18 UTC",
  },
]
  • text: The actual term translation.
  • description: Term translation description
  • status: Term Translation status. One of approved, refused, proposed.

Example Implementation in Ruby

require "net/http"
http = Net::HTTP.new("webtranslateit.com", 443)
request = Net::HTTP::Post.new("/api/projects/:api_token/terms/:term_id/locales/fr/translations")
http.request(request)

Example Implementation in PHP

<?php
$api_key = "sekret";
$term_id = "1234";
$locale_code = "fr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/". $term_id . "/locales/" . $locale_code . "/translations.json");
$response = curl_exec($ch);
$p = json_decode($response, true);
print_r($p);
curl_close($ch);
?>

Create Term Translation

This endpoint is only accessible by the private Project API key and is used to create a new term translation.

/api/projects/:project_token/terms/:term_id/locales/:locale_code/translations [POST]

Parameters

A JSON object modelled after the following:

{
  "text": "Utilisateur",
  "description": "Une personne utilisant WebTranslateIt."
  "status": "approved",
}

description and status are optional.

status can be one of approved, proposed or refused.

If everything goes Well, WebTranslateIt will respond with 201 Created in the header and a JSON representation of the string just created in the body.

Example Implementation in Ruby

require "net/http"
require "json"
http = Net::HTTP.new("webtranslateit.com", 443)
request = Net::HTTP::Post.new("/api/projects/:api_token/terms/:term_id/locales/fr/translations", { "Content-Type" => "application/json" })
request.body = { "text" => "Utilisateur", "status" => "approved" }.to_json
http.request(request)

Example Implementation in PHP

<?php
$api_key = "sekret";
$term_id = "1234";
$locale_code = "fr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/". $term_id . "/locales/" . $locale_code . "/translations.json");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("text" => "Utilisateur", "status" => "approved")); 
$response = curl_exec($ch);
$p = json_decode($response, true);
print_r($p);
curl_close($ch);
?>

Update Term Translation

This endpoint is only accessible by the private Project API key and is used to update a term translation.

/api/projects/:project_token/terms/:term_id/locales/:locale_code/translations/:term_translation_id [PUT]

Parameters

A JSON object modelled after the following:

{
  "text": "Utilisateur",
  "description": "Une personne utilisant WebTranslateIt."
  "status": "refused",
}

description and status are optional.

status can be one of approved, proposed or refused.

If everything goes Well, WebTranslateIt will respond with 202 Accepted in the header and a JSON representation of the string just created in the body.

Example Implementation in Ruby

require "net/http"
require "json"
http = Net::HTTP.new("webtranslateit.com", 443)
request = Net::HTTP::Put.new("/api/projects/:api_token/terms/:term_id/locales/fr/translations/:term_translation_id", { "Content-Type" => "application/json" })
request.body = { "text" => "Utilisateur", "status" => "approved" }.to_json
http.request(request)

Example Implementation in PHP

<?php
$api_key = "sekret";
$term_id = "1234";
$locale_code = "fr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://webtranslateit.com/api/projects/" . $api_key . "/terms/". $term_id . "/locales/" . $locale_code . "/translations/term_translation_id");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, array("text" => "Utilisateur", "status" => "approved")); 
$response = curl_exec($ch);
$p = json_decode($response, true);
print_r($p);
curl_close($ch);
?>