Drupal 8: Get The Current Language

26th April 2016

To get the currently selected language on a Drupal 8 site you need to run the following.

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

This will return the 2 character ISO language code for the language. So for English this would be "en".

To get the language name instead of the language code use this.

$language =  \Drupal::languageManager()->getCurrentLanguage()->getName();


It,s really helpful. Thank you so much.

Sarah Jay (Tue, 08/30/2016 - 20:46)


Short, cool and informative. Thank you!

Josip Rajkovic (Wed, 10/17/2018 - 15:04)


Small remark,

To get the currently selected language for content :

$language = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();

tty11 (Thu, 02/07/2019 - 09:17)

Add new comment

The content of this field is kept private and will not be shown publicly.