function _locale_string_edit in Drupal 5
Same name and namespace in other branches
- 4 includes/locale.inc \_locale_string_edit()
User interface for string editing.
1 call to _locale_string_edit()
- locale_admin_string_edit in modules/
locale/ locale.module - Display the string edit form.
File
- includes/
locale.inc, line 395 - Admin-related functions for locale.module.
Code
function _locale_string_edit($lid) {
$languages = locale_supported_languages(FALSE, TRUE);
unset($languages['name']['en']);
$result = db_query('SELECT DISTINCT s.source, t.translation, t.locale FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid WHERE s.lid = %d', $lid);
$form = array();
$form['translations'] = array(
'#tree' => TRUE,
);
while ($translation = db_fetch_object($result)) {
$orig = $translation->source;
// Approximate the number of rows in a textfield with a maximum of 10.
$rows = min(ceil(str_word_count($orig) / 12), 10);
$form['translations'][$translation->locale] = array(
'#type' => 'textarea',
'#title' => $languages['name'][$translation->locale],
'#default_value' => $translation->translation,
'#rows' => $rows,
);
unset($languages['name'][$translation->locale]);
}
// Handle erroneous lid.
if (!isset($orig)) {
drupal_set_message(t('String not found.'));
drupal_goto('admin/settings/locale/string/search');
}
// Add original text. Assign negative weight so that it floats to the top.
$form['item'] = array(
'#type' => 'item',
'#title' => t('Original text'),
'#value' => check_plain(wordwrap($orig, 0)),
'#weight' => -1,
);
foreach ($languages['name'] as $key => $lang) {
$form['translations'][$key] = array(
'#type' => 'textarea',
'#title' => $lang,
'#rows' => $rows,
);
}
$form['lid'] = array(
'#type' => 'value',
'#value' => $lid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save translations'),
);
return $form;
}