interface TranslatorInterface

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/StringTranslation/Translator/TranslatorInterface.php \Drupal\Core\StringTranslation\Translator\TranslatorInterface
Same name in other branches
  1. 9 core/lib/Drupal/Core/StringTranslation/Translator/TranslatorInterface.php \Drupal\Core\StringTranslation\Translator\TranslatorInterface
  2. 9 core/lib/Drupal/Core/Validation/TranslatorInterface.php \Drupal\Core\Validation\TranslatorInterface
  3. 10 core/lib/Drupal/Core/StringTranslation/Translator/TranslatorInterface.php \Drupal\Core\StringTranslation\Translator\TranslatorInterface
  4. 10 core/lib/Drupal/Core/Validation/TranslatorInterface.php \Drupal\Core\Validation\TranslatorInterface
  5. 11.x core/lib/Drupal/Core/StringTranslation/Translator/TranslatorInterface.php \Drupal\Core\StringTranslation\Translator\TranslatorInterface
  6. 11.x core/lib/Drupal/Core/Validation/TranslatorInterface.php \Drupal\Core\Validation\TranslatorInterface

Defines an interface used in validation.

This replaces the interface used by the Symfony validator in order to indicate that the Drupal code is actually independent from the Symfony translation component.

Hierarchy

Expanded class hierarchy of TranslatorInterface

All classes that implement TranslatorInterface

See also

https://github.com/symfony/symfony/pull/6189

https://github.com/symfony/symfony/issues/15714

3 files declare their use of TranslatorInterface
ConstraintViolationBuilder.php in core/lib/Drupal/Core/TypedData/Validation/ConstraintViolationBuilder.php
ExecutionContext.php in core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php
ExecutionContextFactory.php in core/lib/Drupal/Core/TypedData/Validation/ExecutionContextFactory.php

File

core/lib/Drupal/Core/Validation/TranslatorInterface.php, line 15

Namespace

Drupal\Core\Validation
View source
interface TranslatorInterface {
    
    /**
     * Translates the given message.
     *
     * @param string $id
     *   The message id (may also be an object that can be cast to string).
     * @param array $parameters
     *   An array of parameters for the message.
     * @param string|null $domain
     *   The domain for the message or null to use the default.
     * @param string|null $locale
     *   The locale or null to use the default.
     *
     * @return string
     *   The translated string.
     *
     * @throws InvalidArgumentException
     *   If the locale contains invalid characters.
     */
    public function trans($id, array $parameters = [], $domain = NULL, $locale = NULL);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
TranslatorInterface::trans public function Translates the given message. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.