diff --git a/stringoverrides.module b/stringoverrides.module index d613150..1e24b7f 100644 --- a/stringoverrides.module +++ b/stringoverrides.module @@ -13,6 +13,7 @@ function stringoverrides_help($path, $arg) { case 'admin/help#stringoverrides': $output = '

' . t('The String Overrides module provides a quick and easy way of replacing text.') . '

'; $output .= '

' . t('To replace a string, enter the complete string that is passed through the t() function. String Overrides cannot translate user-defined content, it can only replace strings wrapped in the t() function. To find the strings you can actually change, open up a module and look for t() function calls. Places where %, @, or ! are used means that the translation contains dynamic information (such as the node type or title in the above examples); these are not translated while the text around them is.', array('@t' => 'http://api.drupal.org/api/function/t')) . '

'; + $output = '

' . t('Overrides with a context of "js" will be applied to JavaScript translations.') . '

'; $output .= theme('item_list', array( 'title' => t('Examples'), 'items' => array( @@ -98,3 +99,18 @@ function stringoverrides_theme() { ), ); } + +/** + * Implements hook_js_alter(). + */ +function stringoverrides_js_alter(&$javascript) { + global $language; + $translations = variable_get('locale_custom_strings_' . $language->language); + if (isset($translations['js'])) { + // Add stringoverrides.js to the page, as well as the overrides into the + // JavaScript settings. + $file = drupal_get_path('module', 'stringoverrides') . '/stringoverrides.js'; + $javascript[$file] = drupal_js_defaults($file); + $javascript['settings']['data'][] = array('stringoverrides' => $translations['js']); + } +}