function _l10n_client_string_list in Localization client 6.2
Same name and namespace in other branches
- 5 l10n_client.module \_l10n_client_string_list()
- 6 l10n_client.module \_l10n_client_string_list()
- 7 l10n_client.module \_l10n_client_string_list()
String selection has been moved to a jquery-based list. Todo: make this a themeable function.
1 call to _l10n_client_string_list()
- l10n_client_footer in ./
l10n_client.module - Implementation of hook_footer().
File
- ./
l10n_client.module, line 326 - Localization client. Provides on-page translation editing.
Code
function _l10n_client_string_list($strings) {
// Build a list of short string excerpts for a selectable list.
foreach ($strings as $values) {
// Add a class to help identify translated strings
if ($values[1] === TRUE) {
$str_class = 'untranslated';
}
else {
$str_class = 'translated';
}
// TRUE means we don't have translation, so we use the original string,
// so we always have the string displayed on the page in the dropdown.
$original = $values[1] === TRUE ? $values[0] : $values[1];
// Remove HTML tags for display.
$string = strip_tags($original);
if (empty($string)) {
// Edge case where the whole string was HTML tags. For the
// user to be able to select anything, we need to show part
// of the HTML tags. Truncate first, so we do not truncate in
// the middle of an already escaped HTML tag, thus possibly
// breaking the page.
$string = htmlspecialchars(truncate_utf8($original, 78, TRUE, TRUE), ENT_NOQUOTES, 'UTF-8');
}
else {
// Truncate and add ellipsis if too long.
$string = truncate_utf8($string, 78, TRUE, TRUE);
}
$select_list[] = "<li class='{$str_class}'>{$string}</li>";
}
$output = implode("\n", $select_list);
return "<ul class='string-list'>{$output}</ul>";
}