/**
  * Translates a string to the current language or to a given language.
  *
  * See the t() documentation for details.
  */
 protected static function t($string, array $args = array(), array $options = array())
 {
     if (empty(static::$translationManager)) {
         static::$translationManager = \Drupal::service('string_translation');
     }
     return static::$translationManager->translate($string, $args, $options);
 }
 /**
  * Provides a label for a property by its relationship to a context.
  *
  * @param \Drupal\Core\Field\BaseFieldDefinition $property
  *   The property for which to generate a label.
  * @param \Drupal\Core\Plugin\Context\ContextInterface $context
  *   The context to which the property is related.
  * @param $context_id
  *   The context from the previous parameter's id in the contexts array.
  *
  * @return \Drupal\Core\StringTranslation\TranslatableMarkup
  *   A label for this property for use in user interfaces.
  */
 protected function getRelatedPropertyLabel(BaseFieldDefinition $property, ContextInterface $context, $context_id)
 {
     /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
     $label = $property->getFieldStorageDefinition()->getLabel();
     $string = "@context_id: {$label->getUntranslatedString()}";
     $args = $label->getArguments();
     $args['@context_id'] = !empty($context->getContextDefinition()->getLabel()) ? $context->getContextDefinition()->getLabel() : "{$context_id}";
     $options = $label->getOptions();
     // @todo we need to really think about this label. It informs the UI extensively and should be as clear as possible.
     return $this->translation->translate($string, $args, $options);
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function runCommonBuild(JuiceboxGalleryInterface $gallery, $settings, $data = NULL)
 {
     $global_settings = $this->getGlobalSettings();
     // Add all gallery options directly from the settings.
     $this->setGalleryOptions($gallery, $settings);
     // Also attempt to translate interface strings.
     if ($global_settings['translate_interface']) {
         $base_string = $global_settings['base_languagelist'];
         if (!empty($base_string)) {
             $gallery->addOption('languagelist', Html::escape($this->stringTranslation->translate($base_string)), FALSE);
         }
     }
     // Allow other modules to alter the built gallery data before it's
     // rendered. After this point the gallery should no longer change.
     $this->moduleManager->alter('juicebox_gallery', $gallery, $data);
 }
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $errors = parent::validate();
     $pager_options = $this->displayHandler->getOption('pager');
     if (isset($pager_options['type']) && !($pager_options['type'] == 'none' || $pager_options['type'] == 'some')) {
         // @todo: Re-enable this error once issue #2579931 is resolved.
         // $errors[] = $this->stringTranslation->translate('The Juicebox style cannot be used with a pager. Please disable the "Use a pager" option for this display.');
     }
     $style = $this->displayHandler->getOption('style');
     // We want to somewhat "nag" the user if they have not yet configured the
     // Juicebox-specific plugin settings (because things won't work until they
     // do). However, we do NOT want to formally set an error. This is because
     // this validate method can run on pages where the user can't actaully touch
     // the Juicebox-specific plugin settings (such as
     // admin/structure/views/add).
     if (empty($style['options']['image_field']) || empty($style['options']['thumb_field'])) {
         drupal_set_message($this->stringTranslation->translate("To ensure a fully functional Juicebox gallery please remember to add at least one field of type Image, File or File ID to your Juicebox view display, and to configure all Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning."), 'warning', FALSE);
     }
     return $errors;
 }
 /**
  * Translates a string to the current language or to a given language.
  *
  * @see \Drupal\Core\StringTranslation\TranslationInterface()
  */
 protected function t($string, array $args = array(), array $options = array())
 {
     return $this->translation ? $this->translation->translate($string, $args, $options) : String::format($string, $args);
 }