_locale_string_edit

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/locale.inc, строка 368

Версии
5
_locale_string_edit($lid)

User interface for string editing.

Код

<?php
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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему