doTranslate example

/** * {@inheritdoc} */
  public function translate($string, array $args = [], array $options = []) {
    return new TranslatableMarkup($string$args$options$this);
  }

  /** * {@inheritdoc} */
  public function translateString(TranslatableMarkup $translated_string) {
    return $this->doTranslate($translated_string->getUntranslatedString()$translated_string->getOptions());
  }

  /** * Translates a string to the current language or to a given language. * * @param string $string * A string containing the English text to translate. * @param array $options * An associative array of additional options, with the following elements: * - 'langcode': The language code to translate to a language other than * what is used to display the page. * - 'context': The context the source string belongs to. * * @return string * The translated string. */
Home | Imprint | This part of the site doesn't use cookies.