Please consider that API 2.0 is now the preferred version to be used. The old API will remain fully functional until the end of 2021.
Name | Value | Description |
---|---|---|
files required | array | Files array that should be updated. Note! 20 files max are allowed to upload per one time file transfer. |
titles optional | array | An arrays of strings that defines titles for uploaded files. Array keys should contain file names with path in Crowdin project. |
export_patterns optional | array | An arrays of strings that defines names of resulted files (translated files in resulted archive). Array keys should contain file names with path in Crowdin project. |
new_names optional | array | An arrays of strings that defines new names for previously imported files. Array keys should contain file names with path in Crowdin project. |
first_line_contains_header CSV and XLS/XLSX files only optional | string | Used when uploading CSV (or XLS/XLSX) files via API. Defines whether first line should be imported or it contains columns headers. May not contain value. |
scheme CSV and XLS/XLSX files only required | string | Note: Used only when uploading CSV (or XLS/XLSX) file to define data columns mapping. Acceptable value is the combination of the following constants:
Note: for exported file to contain translations to all the target languages, specify language codes in scheme (e.g. &scheme=identifier,source_phrase,uk,ru,fr). |
update_option optional | string | Depending on the value, "update_option" is used to preserve translations and preserve/remove validations of changed strings during file update. The values are:
|
branch optional | string | The name of related version branch (Versions Management). |
json optional | string | May not contain value. Defines that response should be in JSON format. |
jsonp optional | string | Callback function name. Defines that response should be in JSONP format. |
escape_quotes properties files only optional | integer | Defines whether single quote should be escaped by another single quote or backslash in exported translations. Acceptable values are: 0, 1, 2, 3. Default is 3. 0 — Do not escape single quote; 1 — Escape single quote by another single quote; 2 — Escape single quote by backslash; 3 — Escape single quote by another single quote only in strings containing variables ( {0} ) |
Variables | ||
project-identifier | string | Project identifier. |
login | string | Your username in Crowdin. |
account-key | string | Your account API key. |
<?xml version="1.0" encoding="UTF-8"?>
<success>
</success>
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>3</code>
<message>API key is not valid</message>
</error>
curl \
-F "files[/directory/strings.xml]=@strings.xml" \
https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}
curl \
-F "files[/directory/android.xml]=@strings.xml" \
-F "new_names[/directory/android.xml]=strings.xml" \
https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}
curl \
-F "files[directory/multilingual.csv]=@example.csv" \
-F "export_patterns[directory/multilingual.csv]=/translations/%original_file_name%" \
-F "titles[directory/multilingual.csv]=Title in Crowdin Project" \
-F "scheme=identifier,source_phrase,translation" \
-F "first_line_contains_header=true" \
https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}
<?php
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}';
if (function_exists('curl_file_create')) {
$post_params['files[test.txt]'] = curl_file_create('/home/user/test.txt');
} else {
$post_params['files[test.txt]'] = '@/home/user/test.txt';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
<?php
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}';
if (function_exists('curl_file_create')) {
$post_params['files[/directory/android.xml]'] = curl_file_create('/home/user/strings.xml');
} else {
$post_params['files[/directory/android.xml]'] = '@/home/user/strings.xml';
}
$post_params['new_names[/directory/android.xml]'] = 'strings.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
<?php
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/{project-identifier}/update-file?login={username}&account-key={account-key}';
if(function_exists('curl_file_create')) {
$post_params['files[directory/multilingual.csv]'] = curl_file_create('/home/user/example.csv');
} else {
$post_params['files[directory/multilingual.csv]'] = '@/home/user/example.csv';
}
$post_params['export_patterns[directory/multilingual.csv]'] = '/translations/%original_file_name%';
$post_params['titles[directory/multilingual.csv]'] = 'Title in Crowdin Project';
$post_params['scheme'] = 'identifier,source_phrase,translation';
$post_params['first_line_contains_header'] = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
echo $result;