Give the gift of Drupal. All merchandise is 50% off through 2016.
Drupal 6 used to have a $language global to signify *the* page language. In Drupal 7 this was extended to several language types, so $language, $language_content and $language_url are the three built-in language contexts/globals. Drupal 8 is about to introduce a context system (see WSCCI) and the language values need to be namespaced properly to group together. Also, the use of $language as a global made it dangerous to use $language in a local context (eg. inside methods, functions) because the possibility to clash with the global and overwrite the value. There was no $account vs. $user as in Drupal 7.
In Drupal 8 Globals are handled by the dependency injection system. The 'language_manager' (accessible via
Drupal::languageManager() to procedural code) service can be used to retrieve a language object of a given type, e.g.
Drupal\Core\Language::TYPE_INTERFACE. That is also the default argument for the
getLanguage() method, the other types provided by core are
global $language; $output = t('You speak %name', array('%name' => $language->name));
$language = Drupal::languageManager()->getCurrentLanguage(); $output = t('You speak %name', array('%name' => $language->name));