summaryrefslogtreecommitdiff
path: root/modules/locale
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-23 16:00:08 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-11-23 16:00:08 +0000
commit1b4dd805ca9ebcf34815f480533a1069ba63b7e3 (patch)
treeb38a60a5fd251f5583b449c5ce180cb42024d3a7 /modules/locale
parent25f63a896578c8e342acfe7eebcd4e21cf982349 (diff)
downloadbrdo-1b4dd805ca9ebcf34815f480533a1069ba63b7e3.tar.gz
brdo-1b4dd805ca9ebcf34815f480533a1069ba63b7e3.tar.bz2
#315801 by Rob Loach, Grugnoh2, mfer and dmitrig01: Add a hook_js_alter() to modify JavaScript being printed to the page.
Diffstat (limited to 'modules/locale')
-rw-r--r--modules/locale/locale.module11
1 files changed, 5 insertions, 6 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 15629d3b8..99fe894f3 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -505,21 +505,18 @@ function locale_system_update($components) {
}
/**
- * Update JavaScript translation file, if required, and add it to the page.
+ * Implementation of hook_js_alter().
*
* This function checks all JavaScript files currently added via drupal_add_js()
* and invokes parsing if they have not yet been parsed for Drupal.t()
* and Drupal.formatPlural() calls. Also refreshes the JavaScript translation
* file if necessary, and adds it to the page.
*/
-function locale_update_js_files() {
+function locale_js_alter(&$javascript) {
global $language;
$dir = file_create_path(variable_get('locale_js_directory', 'languages'));
$parsed = variable_get('javascript_parsed', array());
-
- // Get an array of all the JavaScript added so far.
- $javascript = drupal_add_js();
$files = $new_files = FALSE;
foreach ($javascript as $item) {
@@ -563,7 +560,9 @@ function locale_update_js_files() {
// Add the translation JavaScript file to the page.
if ($files && !empty($language->javascript)) {
- drupal_add_js($dir . '/' . $language->language . '_' . $language->javascript . '.js');
+ // Add the translation JavaScript file to the page.
+ $file = $dir . '/' . $language->language . '_' . $language->javascript . '.js';
+ $javascript[$file] = drupal_js_defaults($file);
}
}