$languageManager = \Drupal::languageManager(); $currentLanguage = $languageManager->getCurrentLanguage()->getId();
$languageManager = \Drupal::languageManager(); $newLanguage = [ 'id' => 'es', 'name' => 'Spanish', 'direction' => LANGUAGE_DIRECTION_RTL, ]; $languageManager->addLanguage($newLanguage);
$languageManager = \Drupal::languageManager(); $languageManager->setDefaultLanguage('es');In this code, we use the `setDefaultLanguage()` method to change the default language of the site to Spanish ('es'). Overall, the LanguageManager in Drupal is a useful tool for managing multilingual support on a website. The package for it is part of Drupal core, so it is included by default in every installation of Drupal.