--- modules\locale\locale.module +++ modules\locale\locale.module @@ -548,10 +549,30 @@ // Add the translation JavaScript file to the page. if ($files && !empty($language->javascript)) { + switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { + case FILE_DOWNLOADS_PUBLIC: drupal_add_js($dir .'/'. $language->language .'_'. $language->javascript .'.js', 'core'); + return; + case FILE_DOWNLOADS_PRIVATE: + drupal_add_js('system/files/' . variable_get('locale_js_directory', 'languages') . '/' . $language->language . '_' . $language->javascript . '.js', 'core'); + return; } } +} +/** + * Implementation of hook_file_download() + * Tell Drupal that we need to access Javascript files in this directory if private download is enabled. + */ +function locale_file_download($filepath) { + if (strpos($filepath, variable_get('locale_js_directory', 'languages')) === 0) { + $mime = file_get_mimetype($filepath); + if (strpos($mime, 'javascript') !== false) { + return array('Content-type:' . $mime); + } + } +} + // --------------------------------------------------------------------------------- // Language switcher block