Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / web / core / lib / Drupal / Core / StringTranslation / Translator / CustomStrings.php
1 <?php
2
3 namespace Drupal\Core\StringTranslation\Translator;
4
5 use Drupal\Core\Site\Settings;
6 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
7
8 /**
9  * String translator using overrides from variables.
10  *
11  * This is a high performance way to provide a handful of string replacements.
12  * See settings.php for examples.
13  */
14 class CustomStrings extends StaticTranslation {
15
16   use DependencySerializationTrait;
17
18   /**
19    * The settings read only object.
20    *
21    * @var \Drupal\Core\Site\Settings
22    */
23   protected $settings;
24
25   /**
26    * Constructs a CustomStrings object.
27    *
28    * @param \Drupal\Core\Site\Settings $settings
29    *   The settings read only object.
30    */
31   public function __construct(Settings $settings) {
32     parent::__construct();
33     $this->settings = $settings;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   protected function getLanguage($langcode) {
40     return $this->settings->get('locale_custom_strings_' . $langcode, []);
41   }
42
43 }