protected function PHPTransliteration::readLanguageOverrides

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php \Drupal\Component\Transliteration\PHPTransliteration::readLanguageOverrides()
  2. 9.x drupal/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php \Drupal\Core\Transliteration\PHPTransliteration::readLanguageOverrides()

Reads in language overrides for a language code.

The data is read from files named "$langcode.php" in PHPTransliteration::$dataDirectory. These files should set up an array variable $overrides with an element whose key is $langcode and whose value is an array whose keys are character codes, and whose values are their transliterations in this language.

Parameters

$langcode: Code for the language to read.

2 calls to PHPTransliteration::readLanguageOverrides()
PHPTransliteration::readLanguageOverrides in drupal/core/lib/Drupal/Core/Transliteration/PHPTransliteration.php
Overrides \Drupal\Component\Transliteration\PHPTransliteration::readLanguageOverrides().
PHPTransliteration::replace in drupal/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php
Replaces a single Unicode character using the transliteration database.
1 method overrides PHPTransliteration::readLanguageOverrides()

File

drupal/core/lib/Drupal/Component/Transliteration/PHPTransliteration.php, line 180
Definition of \Drupal\Component\Transliteration\PHPTransliteration.

Class

PHPTransliteration
Implements transliteration without using the PECL extensions.

Namespace

Drupal\Component\Transliteration

Code

protected function readLanguageOverrides($langcode) {

  // Figure out the file name to use by sanitizing the language code,
  // just in case.
  $file = $this->dataDirectory . '/' . preg_replace('[^a-zA-Z\\-]', '', $langcode) . '.php';

  // Read in this file, which should set up a variable called $overrides,
  // which will be local to this function.
  if (is_file($file)) {
    include $file;
  }
  if (!isset($overrides) || !is_array($overrides)) {
    $overrides = array(
      $langcode => array(),
    );
  }
  $this->languageOverrides[$langcode] = $overrides[$langcode];
}