示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config)
 {
     /** @var \Drupal\Core\Datetime\DateFormatter $date_formatter */
     $date_formatter = \Drupal::service('date.formatter');
     $description = $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php'));
     $format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)));
     return ['#type' => 'textfield', '#description' => $description, '#field_suffix' => ' <small data-drupal-date-formatter="preview">' . $format . '</small>', '#attributes' => ['data-drupal-date-formatter' => 'source'], '#attached' => ['drupalSettings' => ['dateFormats' => $date_formatter->getSampleDateFormats($translation_language->getId())], 'library' => ['system/drupal.system.date']]] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config)
 {
     // Estimate a comfortable size of the input textarea.
     $rows_words = ceil(str_word_count($translation_config) / 5);
     $rows_newlines = substr_count($translation_config, "\n") + 1;
     $rows = max($rows_words, $rows_newlines);
     return array('#type' => 'textarea', '#rows' => $rows) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config)
 {
     return array('#type' => 'text_format', '#default_value' => $translation_config['value'], '#format' => $translation_config['format'], '#allowed_formats' => array($source_config['format'])) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function setConfig(Config $base_config, LanguageConfigOverride $config_translation, $config_values, $base_key = NULL)
 {
     $config_values = implode(LOCALE_PLURAL_DELIMITER, $config_values);
     parent::setConfig($base_config, $config_translation, $config_values, $base_key);
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config)
 {
     return array('#type' => 'textfield') + parent::getTranslationElement($translation_language, $source_config, $translation_config);
 }
示例#6
0
 /**
  * {@inheritdoc}
  */
 public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config)
 {
     $description = $this->t('A user-defined date format. See the <a href="@url">PHP manual</a> for available options.', array('@url' => 'http://php.net/manual/function.date.php'));
     $format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $translation_config)));
     return array('#type' => 'textfield', '#description' => $description, '#field_suffix' => ' <div class="edit-date-format-suffix"><small id="edit-date-format-suffix">' . $format . '</small></div>', '#ajax' => array('callback' => 'Drupal\\config_translation\\FormElement\\DateFormat::ajaxSample', 'event' => 'keyup', 'progress' => array('type' => 'throbber', 'message' => NULL))) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
 }