You are here

class CustomStrings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

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
string_translator.custom_strings in core/core.services.yml
Drupal\Core\StringTranslation\Translator\CustomStrings

File

core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php, line 18
Contains \Drupal\Core\StringTranslation\Translator\CustomStrings.

Namespace

Drupal\Core\StringTranslation\Translator
View source
class CustomStrings extends StaticTranslation {

  /**
   * 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, array());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CustomStrings::$settings protected property The settings read only object.
CustomStrings::getLanguage protected function Add translations for new language. Overrides StaticTranslation::getLanguage
CustomStrings::__construct public function Constructs a CustomStrings object. Overrides StaticTranslation::__construct
StaticTranslation::$translations protected property String translations
StaticTranslation::getStringTranslation public function Retrieves English string to given language. Overrides TranslatorInterface::getStringTranslation
StaticTranslation::reset public function Resets translation cache. Overrides TranslatorInterface::reset