function l10n_client_footer in Localization client 5
Same name and namespace in other branches
- 6.2 l10n_client.module \l10n_client_footer()
- 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 130 - Localization client. Provides on-page translation editing.
Code
function l10n_client_footer() {
global $conf, $locale;
if (user_access('use on-page translation') && ($strings = _l10n_client_page_strings())) {
// If we have strings for the page language, restructure the data.
$l10n_strings = array();
foreach ($strings as $string => $translation) {
// Translations can be now an object (lid, translation) or a plain string, it will work with both.
$l10n_strings[] = is_object($translation) ? array(
$string,
empty($translation->translation) ? TRUE : $translation->translation,
$translation->lid,
) : array(
$string,
$translation,
0,
);
}
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');
// We need this hack as JS addition does not work this late on the page.
//$l10n_json = '<script type="text/javascript">Drupal.extend({ l10nStrings: '. drupal_to_js($l10n_strings) .' });</script>';
$l10n_dom = _l10n_client_dom_strings($l10n_strings);
// UI Labels
$string_label = '<h2>' . t('Page Text') . '</h2>';
$source_label = '<h2>' . t('Source') . '</h2>';
// Get language name
$languages = locale_supported_languages();
$languages = $languages['name'];
$translation_label = '<h2>' . t('Translation to %language', array(
'%language' => $languages[$locale],
)) . '</h2>';
$toggle_label = t('Translate Text');
$output = "\n <div id='l10n-client' class='hidden'>\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;
}
}