function l10n_client_translate_page in Localization client 7
Same name and namespace in other branches
- 5 l10n_client.module \l10n_client_translate_page()
- 6.2 l10n_client.module \l10n_client_translate_page()
- 6 l10n_client.module \l10n_client_translate_page()
Menu callback. Translation pages.
These pages just list strings so they can be added to the string list for translation below the page. This can be considered a hack, since we could just implement the same UI on the page, and do away with these artifical listings, but the current UI works, so we just reuse it this way.
This includes custom textgroup support that can be used manually or by other modules.
Parameters
$display_translated: Boolean indicating whether translated or untranslated strings are displayed.
$textgroup: Internal name of textgroup to use.
$allow_translation: Boolean indicating whether translation of strings via the l10n_client UI is allowed.
1 string reference to 'l10n_client_translate_page'
- l10n_client_menu in ./
l10n_client.module - Implement hook_menu().
File
- ./
l10n_client.module, line 143 - Localization client. Provides on-page translation editing.
Code
function l10n_client_translate_page($display_translated = FALSE, $textgroup = 'default', $allow_translation = TRUE) {
global $language;
$table = array();
$query = db_select('locales_source', 's')
->extend('PagerDefault');
$query
->leftJoin('locales_target', 't', "s.lid = t.lid AND t.language = :lang", array(
':lang' => $language->language,
));
$query
->fields('s', array(
'source',
))
->fields('t', array(
'translation',
'language',
))
->orderBy('s.source');
if ($display_translated) {
$header = array(
t('Source string'),
t('Translation'),
);
$query
->condition('t.translation', '', '!=');
}
else {
$header = array(
t('Source string'),
);
$query
->isNull('t.lid');
}
if (!empty($textgroup)) {
$query
->condition('s.textgroup', $textgroup);
}
// For the 'default' textgroup and English language we don't allow translation.
$allow_translation = $textgroup == 'default' && $language->language == 'en' ? FALSE : $allow_translation;
$result = $query
->limit(L10N_CLIENT_STRINGS)
->execute();
foreach ($result as $data) {
if ($display_translated) {
$table[] = array(
check_plain($data->source),
check_plain($data->translation),
);
if ($allow_translation) {
l10_client_add_string_to_page($data->source, $data->translation, $textgroup);
}
}
else {
$table[] = array(
check_plain($data->source),
);
if ($allow_translation) {
l10_client_add_string_to_page($data->source, TRUE, $textgroup);
}
}
}
$pager = theme('pager');
return $pager . theme('table', array(
'header' => $header,
'rows' => $table,
'empty' => t('No strings found to translate.'),
)) . $pager;
}