TranslationManager::getStringTranslation

public TranslationManager::getStringTranslation($langcode, $string, $context) Retrieves English string to given language. Parameters string $langcode: Language code to translate to. string $string: The source string. string $context: The string context. Return value string|false Translated string if there is a translation, FALSE if not. Overrides TranslatorInterface::getStringTranslation File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 92 Class TranslationManager

TranslationManager::formatPlural

public TranslationManager::formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) Formats a string containing a count of items. This function ensures that the string is pluralized correctly. Since TranslationInterface::translate() is called by this function, make sure not to pass already-localized strings to it. See PluralTranslatableMarkup::createFromTranslatedString() for that. For example: $output = $string_translation->formatPlural($node->comment_c

TranslationManager::doTranslate

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 tr

TranslationManager::addTranslator

public TranslationManager::addTranslator(TranslatorInterface $translator, $priority = 0) Appends a translation system to the translation chain. Parameters \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator: The translation interface to be appended to the translation chain. int $priority: The priority of the logger being added. Return value $this File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 66 Class TranslationManager Defines a chained tr

TranslationManager::$translators

An unsorted array of arrays of active translators. An associative array. The keys are integers that indicate priority. Values are arrays of TranslatorInterface objects. Type: \Drupal\Core\StringTranslation\Translator\TranslatorInterface[][] See also \Drupal\Core\StringTranslation\TranslationManager::addTranslator() \Drupal\Core\StringTranslation\TranslationManager::sortTranslators() File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 24 Class TranslationManager Define

TranslationManager::$sortedTranslators

An array of translators, sorted by priority. If this is NULL a rebuild will be triggered. Type: null|\Drupal\Core\StringTranslation\Translator\TranslatorInterface[] See also \Drupal\Core\StringTranslation\TranslationManager::addTranslator() \Drupal\Core\StringTranslation\TranslationManager::sortTranslators() File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 36 Class TranslationManager Defines a chained translation implementation combining multiple translators. Nam

TranslationManager::$defaultLangcode

The default langcode used in translations. A language code. Type: string File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 44 Class TranslationManager Defines a chained translation implementation combining multiple translators. Namespace Drupal\Core\StringTranslation Code protected $defaultLangcode;

TranslationManager

Defines a chained translation implementation combining multiple translators. Hierarchy class \Drupal\Core\StringTranslation\TranslationManager implements TranslationInterface, TranslatorInterface File core/lib/Drupal/Core/StringTranslation/TranslationManager.php, line 11 Namespace Drupal\Core\StringTranslation Members Name Modifiers Type Description TranslationManager::$defaultLangcode protected property The default langcode used in translations. TranslationManager::$s

TranslationInterface::translate

public TranslationInterface::translate($string, array $args = array(), array $options = array()) Translates a string to the current language or to a given language. Never call this translate() method directly. In order for strings to be localized, make them available in one of the ways supported by the Localization API. When possible, use the \Drupal\Core\StringTranslation\StringTranslationTrait $this->t(). Otherwise create a new \Drupal\Core\StringTranslation\TranslatableMarkup object. Para

TranslationInterface::formatPlural

public TranslationInterface::formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) Formats a string containing a count of items. This function ensures that the string is pluralized correctly. Since TranslationInterface::translate() is called by this function, make sure not to pass already-localized strings to it. See PluralTranslatableMarkup::createFromTranslatedString() for that. For example: $output = $string_translation->formatPlural($node->comment