By editor, 6 November, 2015 Question Como obter o idioma actualmente seleccionado (pÔgina atual ou usuÔrio de idioma) por meio de programação em Drupal8 ? o Drupal 8 //Para obter o lanuage código: $idioma = \Drupal::languageManager()->getCurrentLanguage()->getId(); //Para obter o nome do idioma: $idioma = \Drupal::languageManager()->getCurrentLanguage()->getName(); o Drupal 7 global $language; $language=$language->language; Tags Drupal 8 Code Translation User Add new comment Comments7 You must have JavaScript enabled to use this form. Your name Subject Comment About text formats Text format Plain textBasic_html Plain text No HTML tags allowed. Lines and paragraphs break automatically. Web page addresses and email addresses turn into links automatically. To get all enabled language⦠To get all enabled language in drupal 8 : \Drupal::languageManager()->getLanguages(); This may be helpful to any one. Reply Yes Yes, Thank you :) Reply Replacement of global $language Drupal 7: global $language; // return lang code; return $language->language; Drupal 8: return $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); Reply Thanks its work for me :) Thanks its work for me :) Reply Thank you! I couldn't figure⦠Thank you! I couldn't figure out how to call this. Reply thanks thank you worked like a charm Reply Current language in current language And how do I get the current language in the current language, not "French" but "Français"? Reply
To get all enabled language⦠To get all enabled language in drupal 8 : \Drupal::languageManager()->getLanguages(); This may be helpful to any one. Reply
Replacement of global $language Drupal 7: global $language; // return lang code; return $language->language; Drupal 8: return $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); Reply
Current language in current language And how do I get the current language in the current language, not "French" but "FranƧais"? Reply
Comments7
To get all enabled languageā¦
To get all enabled language in drupal 8 :
\Drupal::languageManager()->getLanguages();
This may be helpful to any one.
Yes
Yes, Thank you :)
Replacement of global $language
Drupal 7:
global $language;
// return lang code;
return $language->language;
Drupal 8:
return $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
Thanks its work for me :)
Thanks its work for me :)
Thank you! I couldn't figureā¦
Thank you! I couldn't figure out how to call this.
thanks
thank you worked like a charm
Current language in current language
And how do I get the current language in the current language, not "French" but "FranƧais"?