3

In the Language selection block, I have only the possibility to use the full language name. How can I change it to use the language code, for example FR instead of French?

1
  • 1
    @Vasmir, this is not a good practice, since all the modifications will be lost upon future update. Commented Mar 13, 2017 at 10:29

2 Answers 2

3

One possible solution would be to insert this snippet in your .theme file

In this example I am using bartik as a theme.

/**
 * Implements hook_preprocess_HOOK() for block.html.twig.
 */
function bartik_preprocess_block(&$variables) {
  if ($variables['plugin_id'] == 'language_block:language_interface') {
    foreach ($variables['content']['#links'] as $key => $value) {
      $variables['content']['#links'][$key]['title'] = strtoupper($key);
    }
  }
}

Please, let me know if this solution works for you.

Best regards,

Oleg

2
  • thx, that worked!
    – jimi
    Commented Mar 13, 2017 at 12:21
  • I am glad that it worked, cheers. Commented Mar 13, 2017 at 12:27
1

An issue for bringing that as settings in Drupal core: https://www.drupal.org/node/2135379

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.