protected TranslationManager::doTranslate($string, array $options = array())
Translates a string to the current language or to a given language.
string $string: A string containing the English text to translate.
array $options: An associative array of additional options, with the following elements:
string The translated string.
protected function doTranslate($string, array $options = array()) { // If a NULL langcode has been provided, unset it. if (!isset($options['langcode']) && array_key_exists('langcode', $options)) { unset($options['langcode']); } // Merge in options defaults. $options = $options + [ 'langcode' => $this->defaultLangcode, 'context' => '', ]; $translation = $this->getStringTranslation($options['langcode'], $string, $options['context']); return $translation === FALSE ? $string : $translation; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StringTranslation!TranslationManager.php/function/TranslationManager::doTranslate/8.1.x