Handle JSON responses from translation file URLs

(DBOINCP-141)
This commit is contained in:
Tristan Olive 2015-02-17 01:40:57 -05:00
parent c2d27a1ac5
commit 32ec9f1ee9
1 changed files with 7 additions and 0 deletions

View File

@ -85,6 +85,13 @@ function boinctranslate_refresh_translations() {
}
$result = drupal_http_request($url, array(), 'GET', NULL, 1, 30);
if ($result AND $result->code != '404' AND $result->data) {
if ($result->data[0] == '{') {
// Process as JSON
$json_data = json_decode($result->data, TRUE);
if (!empty($json_data['content'])) {
$result->data = $json_data['content'];
}
}
// Get the language code from the file and add if not yet supported
$langcode = substr(strstr($result->data, 'Language: '), 10, 2);
if (!$langcode) {