public function StringTranslation::translate in Service Container 7
Same name and namespace in other branches
- 7.2 src/StringTranslation/StringTranslation.php \Drupal\service_container\StringTranslation\StringTranslation::translate()
Translates a string to the current language or to a given language.
Never call translate($user_text) where $user_text is text that a user entered; doing so can lead to cross-site scripting and other security problems.
Parameters
string $string: A string containing the English string to translate.
array $args: An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Utility\SafeMarkup::format() for details.
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 TranslationInterface::translate
See also
\Drupal\Component\Utility\SafeMarkup::format()
File
- src/
StringTranslation/ StringTranslation.php, line 40 - Contains \Drupal\service_container\StringTranslation\StringTranslation.
Class
- StringTranslation
- Provides a t() based string translation.
Namespace
Drupal\service_container\StringTranslationCode
public function translate($string, array $args = array(), array $options = array()) {
return $this->drupal7
->t($string, $args, $options);
}