public function TranslationInterface::translate in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Core/StringTranslation/TranslationInterface.php \Drupal\Core\StringTranslation\TranslationInterface::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.
See also
\Drupal\Component\Utility\SafeMarkup::format()
1 method overrides TranslationInterface::translate()
- StringTranslation::translate in src/
StringTranslation/ StringTranslation.php - Translates a string to the current language or to a given language.
File
- lib/
Drupal/ Core/ StringTranslation/ TranslationInterface.php, line 41 - Contains \Drupal\Core\StringTranslation\TranslationInterface.
Class
- TranslationInterface
- Interface for the translation.manager translation service.
Namespace
Drupal\Core\StringTranslationCode
public function translate($string, array $args = array(), array $options = array());