protected TranslationManager::doTranslate($string, array $options = array())
Translates a string to the current language or to a given language.
Parameters
string $string: A string containing the English text to translate.
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 value
string The translated string.
File
- core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 134
Class
- TranslationManager
- Defines a chained translation implementation combining multiple translators.
Namespace
Drupal\Core\StringTranslation
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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 ; } |
Please login to continue.