class CustomStrings in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php \Drupal\Core\StringTranslation\Translator\CustomStrings
- 10 core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php \Drupal\Core\StringTranslation\Translator\CustomStrings
String translator using overrides from variables.
This is a high performance way to provide a handful of string replacements. See settings.php for examples.
Hierarchy
- class \Drupal\Core\StringTranslation\Translator\StaticTranslation implements TranslatorInterface
- class \Drupal\Core\StringTranslation\Translator\CustomStrings uses DependencySerializationTrait
Expanded class hierarchy of CustomStrings
1 string reference to 'CustomStrings'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses CustomStrings
File
- core/
lib/ Drupal/ Core/ StringTranslation/ Translator/ CustomStrings.php, line 14
Namespace
Drupal\Core\StringTranslation\TranslatorView source
class CustomStrings extends StaticTranslation {
use DependencySerializationTrait;
/**
* The settings read only object.
*
* @var \Drupal\Core\Site\Settings
*/
protected $settings;
/**
* Constructs a CustomStrings object.
*
* @param \Drupal\Core\Site\Settings $settings
* The settings read only object.
*/
public function __construct(Settings $settings) {
parent::__construct();
$this->settings = $settings;
}
/**
* {@inheritdoc}
*/
protected function getLanguage($langcode) {
return $this->settings
->get('locale_custom_strings_' . $langcode, []);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CustomStrings:: |
protected | property | The settings read only object. | |
CustomStrings:: |
protected | function |
Retrieves translations for a given language. Overrides StaticTranslation:: |
|
CustomStrings:: |
public | function |
Constructs a CustomStrings object. Overrides StaticTranslation:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
StaticTranslation:: |
protected | property | String translations | |
StaticTranslation:: |
public | function |
Retrieves English string to given language. Overrides TranslatorInterface:: |
|
StaticTranslation:: |
public | function |
Resets translation cache. Overrides TranslatorInterface:: |