Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jhodgdon on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The function views_language_list(), which was formerly in the views.module file, has been removed.
In its place, there is
\Drupal\views\Plugin\views\PluginBase::listLanguages()
which is available on any Views plugin that inherits this class.
Example usage:
// Simple call to list languages on a Views plugin -- lists only actual languages... Was:
$languages = views_language_list();
// Now:
$languages = $this->listLanguages();
// More complex call to list languages and include "special" languages
// like Site Default and Selected Content Language... Was:
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
'***DEFAULT_LANGUAGE***' => t("Default site language"),
LanguageInterface::LANGCODE_NOT_SPECIFIED => t('Language neutral'),
);
$languages = array_merge($languages, views_language_list());
// Now:
$languages = $this->listLanguages(LanguageInterface::STATE_ALL |
LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
Note that the language codes for special languages have also changed -- change notice: https://www.drupal.org/node/2328581
Impacts:
Module developers