Mar 15, 2019 in Drupal 8

You often need to get the current language in your Drupal 8 custom modules or theme. Here's how to get it:

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