protected function TranslationManagerWrapper::doTranslate in Devel 8
Same name and namespace in other branches
- 8.3 webprofiler/src/StringTranslation/TranslationManagerWrapper.php \Drupal\webprofiler\StringTranslation\TranslationManagerWrapper::doTranslate()
- 8.2 webprofiler/src/StringTranslation/TranslationManagerWrapper.php \Drupal\webprofiler\StringTranslation\TranslationManagerWrapper::doTranslate()
- 4.x webprofiler/src/StringTranslation/TranslationManagerWrapper.php \Drupal\webprofiler\StringTranslation\TranslationManagerWrapper::doTranslate()
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.
Overrides TranslationManager::doTranslate
File
- webprofiler/
src/ StringTranslation/ TranslationManagerWrapper.php, line 37
Class
- TranslationManagerWrapper
- Class TranslationManagerWrapper
Namespace
Drupal\webprofiler\StringTranslationCode
protected function doTranslate($string, array $options = array()) {
// Merge in defaults.
if (empty($options['langcode'])) {
$options['langcode'] = $this->defaultLangcode;
}
if (empty($options['context'])) {
$options['context'] = '';
}
$translation = $this
->getStringTranslation($options['langcode'], $string, $options['context']);
if ($translation) {
$this->translated[$string] = $translation;
}
else {
$this->untranslated[$string] = $string;
}
return $translation === FALSE ? $string : $translation;
}