drupal 8 get enabled languages

To get the enabled languages in Drupal 8, you can use the following code snippet:

$enabled_languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_CONFIGURABLE);

This code uses the languageManager() service provided by Drupal to retrieve the enabled languages. The getLanguages() method is called on the language manager object, and the LanguageInterface::STATE_CONFIGURABLE constant is passed as an argument to get only the languages that are configured and enabled.

The $enabled_languages variable will contain an array of language objects representing the enabled languages in Drupal 8. You can then use this array to perform further operations or access specific properties of each language.

Remember to include the necessary use statement at the beginning of your file to import the LanguageInterface class:

use Drupal\Core\Language\LanguageInterface;

I hope this code snippet helps you in retrieving the enabled languages in Drupal 8. If you have any further questions, feel free to ask!