You are here

function l10n_client_init in Localization client 6

Same name and namespace in other branches
  1. 5 l10n_client.module \l10n_client_init()
  2. 6.2 l10n_client.module \l10n_client_init()
  3. 7 l10n_client.module \l10n_client_init()

Implementation of hook_init().

File

./l10n_client.module, line 95
Localization client. Provides on-page translation editing.

Code

function l10n_client_init() {
  global $conf, $language;
  if (l10n_client_access()) {

    // Turn off the short string cache *in this request*, so we will
    // have an accurate picture of strings used to assemble the page.
    $conf['locale_cache_strings'] = 0;

    // Reset locale cache. If any hook_init() implementation was invoked before
    // this point, that would normally result in all strings loaded into memory.
    // That would go against our goal of displaying only strings used on the page
    // and would hang browsers. Drops any string used for the page before this point.
    locale(NULL, NULL, TRUE);
    drupal_add_css(drupal_get_path('module', 'l10n_client') . '/l10n_client.css', 'module');

    // Add jquery cookie plugin -- this should actually belong in
    // jstools (but hasn't been updated for HEAD)
    drupal_add_js(drupal_get_path('module', 'l10n_client') . '/jquery.hotkeys.js', 'module');
    drupal_add_js(drupal_get_path('module', 'l10n_client') . '/jquery.cookie.js', 'module');
    drupal_add_js(drupal_get_path('module', 'l10n_client') . '/l10n_client.js', 'module');

    // We use textareas to be able to edit long text, which need resizing.
    drupal_add_js('misc/textarea.js', 'module');
  }
}