You are here

function l10n_client_init in Localization client 7

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. 6 l10n_client.module \l10n_client_init()

Implement hook_init().

File

./l10n_client.module, line 89
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.
    drupal_static_reset('locale');
    drupal_add_css(drupal_get_path('module', 'l10n_client') . '/l10n_client.css');
    drupal_add_js(drupal_get_path('module', 'l10n_client') . '/jquery.hotkeys.js');
    drupal_add_js('misc/jquery.cookie.js');
    drupal_add_js(drupal_get_path('module', 'l10n_client') . '/l10n_client.js');

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