function hook_transliteration_overrides_alter

Same name in other branches
  1. 9 core/lib/Drupal/Core/Language/language.api.php \hook_transliteration_overrides_alter()
  2. 8.9.x core/lib/Drupal/Core/Language/language.api.php \hook_transliteration_overrides_alter()
  3. 11.x core/lib/Drupal/Core/Language/language.api.php \hook_transliteration_overrides_alter()

Provide language-specific overrides for transliteration.

If the overrides you want to provide are standard for your language, consider providing a patch for the Drupal Core transliteration system instead of using this hook. This hook can be used temporarily until Drupal Core's transliteration tables are fixed, or for sites that want to use a non-standard transliteration system.

Parameters

array $overrides: Associative array of language-specific overrides whose keys are integer Unicode character codes, and whose values are the transliterations of those characters in the given language, to override default transliterations.

string $langcode: The code for the language that is being transliterated.

Related topics

2 invocations of hook_transliteration_overrides_alter()
MachineName::getTransliterationLanguageOverrides in core/lib/Drupal/Core/Render/Element/MachineName.php
Gets transliteration language overrides for a language.
PhpTransliteration::readLanguageOverrides in core/lib/Drupal/Core/Transliteration/PhpTransliteration.php
Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides().

File

core/lib/Drupal/Core/Language/language.api.php, line 250

Code

function hook_transliteration_overrides_alter(&$overrides, $langcode) {
    // Provide special overrides for German for a custom site.
    if ($langcode == 'de') {
        // The core-provided transliteration of Ä is Ae, but we want just A.
        $overrides[0xc4] = 'A';
    }
}

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