You are here

function l10n_client_footer in Localization client 6.2

Same name and namespace in other branches
  1. 5 l10n_client.module \l10n_client_footer()
  2. 6 l10n_client.module \l10n_client_footer()

Implementation of hook_footer().

Output a form to the page and a list of strings used to build the page in JSON form.

File

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

Code

function l10n_client_footer() {
  global $conf, $language;

  // Check permission and get all strings used on the page.
  if (l10n_client_access() && ($page_strings = _l10n_client_page_strings())) {

    // If we have strings for the page language, restructure the data.
    $l10n_strings = array();
    foreach ($page_strings as $textgroup => $group_strings) {
      foreach ($group_strings as $string => $translation) {
        $l10n_strings[] = array(
          $string,
          $translation,
          $textgroup,
        );
      }
    }
    array_multisort($l10n_strings);

    // Include string selector on page.
    $string_list = _l10n_client_string_list($l10n_strings);

    // Include editing form on page.
    $l10n_form = drupal_get_form('l10n_client_form', $l10n_strings);

    // Include search form on page.
    $l10n_search = drupal_get_form('l10n_client_search_form');

    // Generate HTML wrapper with strings data.
    $l10n_dom = _l10n_client_dom_strings($l10n_strings);

    // UI Labels
    $string_label = '<h2>' . t('Page Text') . '</h2>';
    $source_label = '<h2>' . t('Source') . '</h2>';
    $translation_label = '<h2>' . t('Translation to %language', array(
      '%language' => $language->native,
    )) . '</h2>';
    $toggle_label = t('Translate Text');
    $output = "\n      <div id='l10n-client' class='l10n-client-minimized'>\n        <div class='labels'>\n          <span class='toggle'>{$toggle_label}</span>\n          <div class='label strings'>{$string_label}</div>\n          <div class='label source'>{$source_label}</div>\n          <div class='label translation'>{$translation_label}</div>\n        </div>\n        <div id='l10n-client-string-select'>\n          {$string_list}\n          {$l10n_search}\n        </div>\n        <div id='l10n-client-string-editor'>\n          <div class='source'>\n            <div class='source-text'></div>\n          </div>\n          <div class='translation'>\n            {$l10n_form}\n          </div>\n        </div>\n      </div>\n      {$l10n_dom}\n    ";
    return $output;
  }
}