diff --git a/controller/action/i18nActions.class.php b/controller/action/i18nActions.class.php index 7849d087..e5064692 100644 --- a/controller/action/i18nActions.class.php +++ b/controller/action/i18nActions.class.php @@ -29,14 +29,18 @@ class i18nActions extends Actions throw new Exception('Please set Config::TRANSIFEX_API_KEY in your configuration.'); } - $json = Transifex::getTranslationResourceFile($project, $resource, $language); + $usecache = !Request::getParam('nocache'); + $json = Transifex::getTranslationResourceFile($project, $resource, $language, $usecache); if (!$json) { return NavActions::execute404(); } Response::setHeader(Response::HEADER_CROSS_ORIGIN, "*"); - Response::enablePublicMutableCache(md5(json_encode($json))); + + if ($usecache) { + Response::enablePublicMutableCache(md5(json_encode($json))); + } return View::renderJson($json); } diff --git a/lib/thirdparty/Transifex.class.php b/lib/thirdparty/Transifex.class.php index 4d5393bf..e5cf5032 100644 --- a/lib/thirdparty/Transifex.class.php +++ b/lib/thirdparty/Transifex.class.php @@ -7,12 +7,12 @@ class Transifex return (boolean)Config::get(Config::TRANSIFEX_API_KEY); } - public static function getTranslationResourceFile($project, $resource, $language) + public static function getTranslationResourceFile($project, $resource, $language, $cache = true) { $url = "https://www.transifex.com/api/2/project/$project/resource/$resource/translation/$language?file=1"; return json_decode(CurlWithCache::get($url, [], [ 'password' => 'api:' . Config::get(Config::TRANSIFEX_API_KEY), - 'cache' => 1000 * 60 * 60 * 8 + 'cache' => $cache ? 1000 * 60 * 60 * 8 : false ]), true); } } \ No newline at end of file