How to get current language in Drupal 8

Posted on Thursday, April 6, 2017

Here is the quick code snippet of how we can get the current language in Drupal 8 form multilanguage sites.


Get current language code in Drupal 8:

<?php $language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId(); ?>

Get current language name in Drupal 8:

<?php $language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getName(); ?>

Get all enabled languages in Drupal 8:

<?php $languages = \Drupal::languageManager()-&gt;getLanguages(); ?>



Miltan (not verified)

Thursday, May 11, 2017

I start with thank you for sharing such an informative put up with us. i hope this proportion could be very beneficial for the readers. Moreover, additionally all of the factors with this proportion can be very attractive for the readers. Critiques of is write my essay likewise an amazing source for the readers

hellenjos (not verified)

Monday, June 12, 2017

Thanks for sharing the code to get current language in Drupal 8. I searched many websites to get the code of this but didn’t get any. After seeing this code I become very happy now I can use this code to get the current language in Drupal 8. Keep sharing more related articles like by Cory professional makeup artist

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.