From 32ec9f1ee9d0fd250ff3b9463cdb96355e108cf2 Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Tue, 17 Feb 2015 01:40:57 -0500 Subject: [PATCH] Handle JSON responses from translation file URLs (DBOINCP-141) --- .../boinc/modules/boinctranslate/boinctranslate.module | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module index 57c61e7f2a..39afb13196 100644 --- a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module +++ b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module @@ -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) {