class StringTranslation in Service Container 7
Same name and namespace in other branches
- 7.2 src/StringTranslation/StringTranslation.php \Drupal\service_container\StringTranslation\StringTranslation
Provides a t() based string translation.
@codeCoverageIgnore
Hierarchy
- class \Drupal\service_container\StringTranslation\StringTranslation implements TranslationInterface
Expanded class hierarchy of StringTranslation
1 file declares its use of StringTranslation
- StringTranslationTest.php in tests/
src/ StringTranslation/ StringTranslationTest.php - Contains \Drupal\Tests\service_container\StringTranslation\StringTranslationTest
File
- src/
StringTranslation/ StringTranslation.php, line 18 - Contains \Drupal\service_container\StringTranslation\StringTranslation.
Namespace
Drupal\service_container\StringTranslationView source
class StringTranslation implements TranslationInterface {
/**
* The Drupal7 service.
*
* @var \Drupal\service_container\Legacy\Drupal7
*/
protected $drupal7;
/**
* Constructs a new StringTranslation instance.
*
* @param \Drupal\service_container\Legacy\Drupal7 $drupal7
* The Drupal7 service.
*/
public function __construct(Drupal7 $drupal7) {
$this->drupal7 = $drupal7;
}
/**
* {@inheritdoc}
*/
public function translate($string, array $args = array(), array $options = array()) {
return $this->drupal7
->t($string, $args, $options);
}
/**
* {@inheritdoc}
*/
public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
return $this->drupal7
->format_plural($count, $singular, $plural, $args, $options);
}
/**
* {@inheritdoc}
*/
public function formatPluralTranslated($count, $translation, array $args = array(), array $options = array()) {
throw new \BadMethodCallException('StringTranslation::formatPluralTranslated is not implemented.');
}
/**
* {@inheritdoc}
*/
public function getNumberOfPlurals($langCode = NULL) {
throw new \BadMethodCallException('StringTranslation::getNumberOfPlurals is not implemented.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslation:: |
protected | property | The Drupal7 service. | |
StringTranslation:: |
public | function |
Formats a string containing a count of items. Overrides TranslationInterface:: |
|
StringTranslation:: |
public | function |
Formats an already translated string containing a count of items. Overrides TranslationInterface:: |
|
StringTranslation:: |
public | function |
Returns the number of plurals supported by a given language. Overrides TranslationInterface:: |
|
StringTranslation:: |
public | function |
Translates a string to the current language or to a given language. Overrides TranslationInterface:: |
|
StringTranslation:: |
public | function | Constructs a new StringTranslation instance. |