function MachineName::getTransliterationLanguageOverrides

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Render/Element/MachineName.php \Drupal\Core\Render\Element\MachineName::getTransliterationLanguageOverrides()

Gets transliteration language overrides for a language.

This is duplicating \Drupal\Core\Transliteration\PhpTransliteration::readLanguageOverrides().

See also

\Drupal\Core\Transliteration\PhpTransliteration::readLanguageOverrides()

1 call to MachineName::getTransliterationLanguageOverrides()
MachineName::processMachineName in core/lib/Drupal/Core/Render/Element/MachineName.php
Processes a machine-readable name form element.

File

core/lib/Drupal/Core/Render/Element/MachineName.php, line 290

Class

MachineName
Provides a machine name render element.

Namespace

Drupal\Core\Render\Element

Code

private static function getTransliterationLanguageOverrides(LanguageInterface $language) {
    $overrides =& drupal_static(__CLASS__ . '_' . __METHOD__, []);
    $langcode = $language->getId();
    if (isset($overrides[$langcode])) {
        return $overrides[$langcode];
    }
    $file = dirname(__DIR__, 3) . '/Component/Transliteration/data' . '/' . preg_replace('/[^a-zA-Z\\-]/', '', $langcode) . '.php';
    $overrides[$langcode] = [];
    if (is_file($file)) {
        include $file;
    }
    \Drupal::moduleHandler()->alter('transliteration_overrides', $overrides[$langcode], $langcode);
    return [
        $langcode => $overrides[$langcode],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.