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.
Add a new file to Crowdin project.
Nome | Valor | Descrição |
---|---|---|
files obrigatório | array | Array de ficheiros que deve ser adicionada ao projeto no Crowdin. Array keys should contain file names with a path in Crowdin project. Nota! no máximo são permitidos 20 ficheiros para enviar por transferência por vez. O tamanho máximo de um ficheiro é de 100 MB. |
titles opcional | array | An array of strings that defines titles for uploaded files. Array keys should contain file names with a path in Crowdin project. |
export_patterns opcional | array | An array of strings that defines names of resulted files (translated files in the resulted archive). Array keys should contain file names with a path in Crowdin project. |
type opcional | string | Os valores aceitáveis são:
|
first_line_contains_header apenas ficheiros XLS/XLSX e CSV opcional | string | Used when uploading CSV (or XLS/XLSX) files via API. Defines whether the first line should be imported or it contains the columns headers. May contain no value. |
import_translations apenas ficheiros multilingues CSV e XLS/XLSX opcional | inteiro | Used when uploading CSV (or XLS/XLSX) files via API. Defines whether during the file import translations are imported as well – 1, or translations are not imported – 0. Default: 1. |
esquema ficheiros CSV e XLS/XLSX apenas obrigatório | string | Note: Used only when uploading CSV (or XLS/XLSX) file to define data columns mapping. O valor aceitável é a combinação das seguintes constantes:
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). |
branch opcional | string | The name of the related version branch (Versions Management). |
json opcional | string | May contain no value. Defines that response should be in the JSON format. |
jsonp opcional | string | Nome da função de retorno de chamada. Defines that response should be in the JSONP format. |
translate_content apenas ficheiros XML opcional | bool | Define se deves traduzir os textos colocados dentro das tags. Os valores aceitáveis são: 0 ou 1. O padrão é 1. |
translate_attributes apenas ficheiros XML opcional | bool | Define se os atributos das tags devem ser traduzidos. Os valores aceitáveis são: 0 ou 1. O padrão é 1. |
content_segmentation apenas para ficheiros XML opcional | bool | Define se os textos longos devem ser divididos em segmentos de textos menores. Os valores aceitáveis são: 0 ou 1. O padrão é 1. Importante! Esta opção desativa a possibilidade de enviar traduções existentes para ficheiros XML quando ativada. |
translatable_elements apenas ficheiros XML opcional | array | Este é um array de frases, onde cada item é o XPaths para elemento DOM que deve ser importado. Acceptable values are:
Note! If defined, the parameters "translate_content" and "translate_attributes" are not taken into account while importing. |
escape_quotes apenas ficheiros properties opcional | inteiro | Define se as aspas simples devem ser ignoradas por outra ou barra invertida em traduções exportadas. Os valores aceitáveis são: 0, 1, 2, 3. O padrão é 3. 0 — Não escape duma citação simples; 1 — Escape de aspas simples por outra aspa simples; 2 — Escape de aspas simples por barra invertida; 3 — Escape de aspas simples por outra aspa simples apenas em frases que contém variáveis ( {0} ) |
Variáveis | ||
project-identifier | string | Identificador do projeto. |
login | string | O teu nome de utilizador no Crowdin. |
account-key | string | A tua chave API de conta. |
<?xml version="1.0" encoding="UTF-8"?>
<success>
<stats>
<file file_id="342">
<name>strings.xml</name>
<strings>4</strings>
<words>11</words>
</file>
</stats>
</success>
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>3</code>
<message>A chave API não é válida</message>
</error>
curl \
-F "files[/directory/arrays.xml]=@arrays.xml" \
-F "files[strings.xml]=@strings.xml" \
https://api.crowdin.com/api/project/{project-identifier}/add-file?login={username}&account-key={account-key}
curl \
-F "files[directory/multilingual.csv]=@example.csv" \
-F "export_patterns[directory/multilingual.csv]=/%locale%/%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}/add-file?login={username}&account-key={account-key}
<?php
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/{project-identifier}/add-file?login={username}&account-key={account-key}';
if (function_exists('curl_file_create')) {
$post_params['files[test.txt]'] = curl_file_create('/home/crowdin/test.txt');
} else {
$post_params['files[test.txt]'] = '@/home/crowdin/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}/add-file?login={username}&account-key={account-key}';
if(function_exists('curl_file_create')) {
$post_params['files[directory/multilingual.csv]'] = curl_file_create('/home/crowdin/example.csv');
} else {
$post_params['files[directory/multilingual.csv]'] = '@/home/crowdin/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;