You are here

function l10n_client_init in Localization client 5

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

Implementation of hook_init().

File

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

Code

function l10n_client_init() {
  global $user, $conf, $locale;

  // Check for the function because it may not be loaded on hook_init() for cached pages
  if (function_exists('user_access') && user_access('use on-page translation')) {

    // 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;

    // Option: Delete menu cache so all item titles are run again through t()
    // This is really bad for performance bug good for translators :-)
    // The problem is that the whole menu is added to the translatable strings for this page :-(
    // $cid = "$user->uid:$locale";
    // cache_clear_all($cid, 'cache_menu');
    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.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');
  }
}