Datei aktualisieren

Die neuste Version einer Übersetzungsdatei zu Crowdin hochladen.

Anfrage

Hinweis: Entweder die Kombination aus Projekt-ID und Projektschlüssel oder die Kombination aus Projekt-ID, Nutzername und Kontoschlüssel to pass to this endpoint.

POST https://api.crowdin.com/api/project/{Projekt-ID}/update-file?key={Projektschlüssel}
POST https://api.crowdin.com/api/project/{Projekt-ID}/update-file?login={Nutzername}&account-key={Kontoschlüssel}

Parameter

Name Wert Beschreibung
files benötigt Array Files array that should be updated.
Note! 20 files max are allowed to upload per one time file transfer.
titles optional Array Dateien, die zum Crowdin-Projekt hinzugefügt werden sollten, ordnen sich. Indexschlüssel sollten Dateinamen mit Pfadangabe im Crowdin-Projekt enthalten.
export_patterns optional Array Eine Abfolge von Zeichen, welche die Namen der angezeigten Dateien definiert (übersetzte Dateien im angezeigten Archiv). Indexschlüssel sollten Dateinamen mit Pfadangabe im Crowdin-Projekt enthalten.
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 nur CSV- und XLS- bzw. XLSX-Dateien
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 Hinweis: Used only when uploading CSV (or XLS/XLSX) file to define data columns mapping.
Acceptable value is the combination of the following constants:
  • "identifier" — Column contains string identifier.
  • "source_phrase" — Column contains only source string (in result string will contain same string).
  • "source_or_translation" — Column contains source string but when exporting same column should contain translation (also when uploading existing translations, the value from this column will be used as a translated string).
  • "translation" — Column contains translated string (when imported file already contains translations).
  • "context" — Column contains some comments on source string. Context information.
  • "max_length" — Column contains max. length of translation for this string.
  • "none" — Do not import column.
Example parameter you will have to add: &scheme=identifier,source_or_translation

Hinweis: for exported file to contain translations to all the target languages, specify Sprachcodes in schema (z.B. &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:
  • "update_as_unapproved" — Preserve translations of changed strings and remove validations of those translations if they exist.
  • "update_without_changes" — Preserve translations and validations of changed strings.
Hinweis: If it is not set translations for changed strings will be lost after file update. Useful for typo fixes and minor changes in source strings.
branch optional String Der Name des dazugehörigen Versionszweigs (Versionsverwaltung).
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. Zulässige Werte sind: „0”, „1”, „2” und „3”. Der Standardwert ist 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} )
Variablen
project-identifier String Projekt-ID.
project-key String Projekt-API-Schlüssel. Entweder project-key oder die Kombination aus login und account-key wird benötigt.
login String Ihr Crowdin-Nutzername. Entweder project-key oder die Kombination aus login und account-key wird benötigt.
account-key String Ihr Konto-API-Schlüssel. Entweder project-key oder die Kombination aus login und account-key wird benötigt.

Antwort

Wenn die Methode erfolgreich war, gibt sie eine XML-Struktur zurück, so wie unten zu sehen.
<?xml version="1.0" encoding="ISO-8859-1"?>
<success>
</success>
Beispiel einer fehlgeschlagenen Antwort:
<?xml version="1.0" encoding="ISO-8859-1"?>
<error>
  <code>3</code>
  <message>API key is not valid</message>
</error>

Beispiele

curl \
  -F "files[/directory/strings.xml]=@strings.xml" \
  https://api.crowdin.com/api/project/{Projekt-ID}/update-file?key={Projektschlüssel}
curl \
  -F "files[/directory/android.xml]=@strings.xml" \
  -F "new_names[/directory/android.xml]=strings.xml" \
  https://api.crowdin.com/api/project/{Projekt-ID}/update-file?key={Projektschlüssel}
curl \
  -F "files[directory/multilingual.csv]=@example.csv" \
  -F "export_patterns[directory/multilingual.csv]=/translations/%original_file_name%" \
  -F "titles[directory/multilingual.csv]=Titel im Crowdin-Projekt" \
  -F "scheme=identifier,source_phrase,translation" \
  -F "first_line_contains_header=true" \
  https://api.crowdin.com/api/project/{Projekt-ID}/update-file?key={Projektschlüssel}
<?php
$post_params = array();
$request_url = 'https://api.crowdin.com/api/project/{project-identifier}/update-file?key={project-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?key={project-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?key={project-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;

War dieser Artikel hilfreich?