Get current language programmatically in Drupal 8

The following snippet will return your langcode f.e. 'en', 'nl', etc. Use the following code:

// Get current language code
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!