Documentation
API
TermBase Translation API
The TermBase Translation API is composed of 3 endpoints:
- List Term Translations — list term translations for a term
- Create Term Translation — create a term translation
- Update Term Translation — update a term translation
List Term Translations
This endpoint is only accessible by the read-write 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.
/api/projects/:project_token/terms/:term_id/locales/:locale_code/translations.jsoncurl "https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations.json"
const response = await fetch(
'https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations.json'
)
const translations = await response.json()
import requests
response = requests.get(
"https://webtranslateit.com/api/projects/PROJECT_TOKEN"
"/terms/1234/locales/fr/translations.json"
)
translations = response.json()
require 'net/http'
require 'json'
uri = URI('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations.json')
translations = JSON.parse(Net::HTTP.get(uri))
<?php
$ch = curl_init('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$translations = json_decode(curl_exec($ch), true);
curl_close($ch);
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 descriptionstatus: Term Translation status. One ofapproved,refused,proposed. In the web interface, the status follows the votes cast on the translation: a vote replaces a status set through the API with the one the votes add up to.
Create Term Translation
This endpoint is only accessible by the read-write 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. Any other value is rejected with 422 Unprocessable Content.
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.
/api/projects/:project_token/terms/:term_id/locales/:locale_code/translationscurl -X POST "https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations" \
-H "Content-Type: application/json" \
-d '{
"text": "Utilisateur",
"description": "Une personne utilisant WebTranslateIt.",
"status": "approved"
}'
const response = await fetch(
'https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: 'Utilisateur',
description: 'Une personne utilisant WebTranslateIt.',
status: 'approved'
})
}
)
const translation = await response.json()
import requests
response = requests.post(
"https://webtranslateit.com/api/projects/PROJECT_TOKEN"
"/terms/1234/locales/fr/translations",
json={
"text": "Utilisateur",
"description": "Une personne utilisant WebTranslateIt.",
"status": "approved",
},
)
translation = response.json()
require 'net/http'
require 'json'
uri = URI('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations')
response = Net::HTTP.post(uri, {
text: 'Utilisateur',
description: 'Une personne utilisant WebTranslateIt.',
status: 'approved'
}.to_json, 'Content-Type' => 'application/json')
translation = JSON.parse(response.body)
<?php
$ch = curl_init('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'text' => 'Utilisateur',
'description' => 'Une personne utilisant WebTranslateIt.',
'status' => 'approved',
]));
$translation = json_decode(curl_exec($ch), true);
curl_close($ch);
Update Term Translation
This endpoint is only accessible by the read-write 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 [PATCH]
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. Any other value is rejected with 422 Unprocessable Content.
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.
/api/projects/:project_token/terms/:term_id/locales/:locale_code/translations/:term_translation_idcurl -X PATCH "https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations/5678" \
-H "Content-Type: application/json" \
-d '{ "status": "refused" }'
const response = await fetch(
'https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations/5678',
{
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ status: 'refused' })
}
)
const translation = await response.json()
import requests
response = requests.patch(
"https://webtranslateit.com/api/projects/PROJECT_TOKEN"
"/terms/1234/locales/fr/translations/5678",
json={"status": "refused"},
)
translation = response.json()
require 'net/http'
require 'json'
uri = URI('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations/5678')
request = Net::HTTP::Patch.new(uri, 'Content-Type' => 'application/json')
request.body = {status: 'refused'}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
translation = JSON.parse(response.body)
<?php
$ch = curl_init('https://webtranslateit.com/api/projects/PROJECT_TOKEN/terms/1234/locales/fr/translations/5678');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['status' => 'refused']));
$translation = json_decode(curl_exec($ch), true);
curl_close($ch);