Commit be83ed2b authored by webchick's avatar webchick

Issue #2166915 by ianthomas_uk, sun | plach: Remove uses of deprecated...

Issue #2166915 by ianthomas_uk, sun | plach: Remove uses of deprecated language functions in tests and procedural code.
parent 7a91c2e8
......@@ -821,7 +821,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) {
$languages = array();
// Fill in master language list based on current configuration.
$default = language_default();
$default = \Drupal::languageManager()->getDefaultLanguage();
if (\Drupal::languageManager()->isMultilingual() || \Drupal::moduleHandler()->moduleExists('language')) {
// Use language module configuration if available. We can not use
// entity_load_multiple() because this breaks during updates.
......@@ -858,7 +858,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) {
// Add the site's default language if flagged as allowed value.
if ($flags & Language::STATE_SITE_DEFAULT) {
$default = isset($default) ? $default : language_default();
$default = isset($default) ? $default : \Drupal::languageManager()->getDefaultLanguage();
// Rename the default language.
$default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name));
$filtered_languages['site_default'] = $default;
......
......@@ -66,7 +66,7 @@ public function testCustomBlockTypeCreation() {
$this->assertTrue($block_type, 'The new block type has been created.');
// Check that the block type was created in site default language.
$default_langcode = language_default()->id;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
$this->assertEqual($block_type->langcode, $default_langcode);
}
......
......@@ -93,7 +93,7 @@ protected function createTests() {
'id' => 'test_block',
'weight' => NULL,
'status' => TRUE,
'langcode' => language_default()->id,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id,
'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')),
'theme' => 'stark',
'region' => '-1',
......
......@@ -91,7 +91,7 @@ function testCommentLanguage() {
// is the user language preference. This way we can ensure that node
// language and interface language do not influence comment language, as
// only content language has to.
foreach (language_list() as $node_langcode => $node_language) {
foreach ($this->container->get('language_manager')->getLanguages() as $node_langcode => $node_language) {
// Create "Article" content.
$title = $this->randomName();
$edit = array(
......@@ -104,7 +104,7 @@ function testCommentLanguage() {
$node = $this->drupalGetNodeByTitle($title);
$prefixes = language_negotiation_url_prefixes();
foreach (language_list() as $langcode => $language) {
foreach ($this->container->get('language_manager')->getLanguages() as $langcode => $language) {
// Post a comment with content language $langcode.
$prefix = empty($prefixes[$langcode]) ? '' : $prefixes[$langcode] . '/';
$comment_values[$node_langcode][$langcode] = $this->randomName();
......
......@@ -132,7 +132,7 @@ protected function assertPublishedStatus() {
$entity = entity_load($this->entityTypeId, $this->entityId);
$user = $this->drupalCreateUser(array('access comments'));
$this->drupalLogin($user);
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// Check that simple users cannot see unpublished field translations.
$path = $entity->getSystemPath();
......
......@@ -39,7 +39,7 @@ public static function getInfo() {
* Tests CRUD operations.
*/
function testCRUD() {
$default_langcode = language_default()->id;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
// Verify default properties on a newly created empty entity.
$empty = entity_create('config_test');
$this->assertIdentical($empty->id, NULL);
......
......@@ -58,7 +58,7 @@ function testImport() {
'test_dependencies' => array(),
'status' => TRUE,
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => language_default()->id,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id,
'dependencies' => array(),
'protected_property' => '',
);
......
......@@ -169,7 +169,7 @@ function testNew() {
'test_dependencies' => array(),
'status' => TRUE,
'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
'langcode' => language_default()->id,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id,
'dependencies' => array(),
'protected_property' => '',
);
......
......@@ -115,7 +115,7 @@ function testSiteWideContact() {
// Check that the category was created in site default language.
$langcode = \Drupal::config('contact.category.' . $id)->get('langcode');
$default_langcode = language_default()->id;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
$this->assertEqual($langcode, $default_langcode);
// Make sure the newly created category is included in the list of categories.
......
......@@ -277,7 +277,7 @@ function content_translation_form_language_content_settings_validate(array $form
$values = $bundle_settings['settings']['language'];
if (empty($values['language_show']) && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) {
foreach (language_list(Language::STATE_LOCKED) as $language) {
foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
form_set_error($name, $form_state, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
......
......@@ -94,7 +94,7 @@ function content_translation_install() {
*/
function content_translation_enable() {
// Translation works when at least two languages are enabled.
if (count(language_list()) < 2) {
if (count(\Drupal::languageManager()->getLanguages()) < 2) {
$t_args = array('!language_url' => url('admin/config/regional/language'));
$message = t('Be sure to <a href="!language_url">enable at least two languages</a> to translate content.', $t_args);
drupal_set_message($message, 'warning');
......
......@@ -287,7 +287,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc
$source = !empty($source) ? $source : $entity->language();
$target = !empty($target) ? $target : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
return $source->id != $target->id && isset($languages[$source->id]) && isset($languages[$target->id]) && !isset($translations[$target->id]) && content_translation_access($entity, 'create');
}
......@@ -303,7 +303,7 @@ function content_translation_add_access(EntityInterface $entity, Language $sourc
function content_translation_edit_access(EntityInterface $entity, Language $language = NULL) {
$language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'update');
}
......@@ -319,7 +319,7 @@ function content_translation_edit_access(EntityInterface $entity, Language $lang
function content_translation_delete_access(EntityInterface $entity, Language $language = NULL) {
$language = !empty($language) ? $language : \Drupal::languageManager()->getCurrentLanguage(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) && content_translation_access($entity, 'delete');
}
......@@ -859,7 +859,7 @@ function content_translation_language_configuration_element_validate($element, a
$key = $form_state['content_translation']['key'];
$values = $form_state['values'][$key];
if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) {
foreach (language_list(Language::STATE_LOCKED) as $language) {
foreach (\Drupal::languageManager()->getLanguages(Language::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
// @todo Set the correct form element name as soon as the element parents
......
......@@ -20,7 +20,7 @@
*/
function content_translation_overview(EntityInterface $entity) {
$controller = content_translation_controller($entity->getEntityTypeId());
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
$original = $entity->getUntranslated()->language()->id;
$translations = $entity->getTranslationLanguages();
$administrator = \Drupal::currentUser()->hasPermission('administer languages');
......
......@@ -103,7 +103,7 @@ protected function setupLanguages() {
foreach ($this->langcodes as $langcode) {
language_save(new Language(array('id' => $langcode)));
}
array_unshift($this->langcodes, language_default()->id);
array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->id);
}
/**
......
......@@ -119,7 +119,7 @@ function testWorkflows() {
*/
protected function assertWorkflows(UserInterface $user, $expected_status) {
$default_langcode = $this->langcodes[0];
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
$args = array('@user_label' => $user->getUsername());
$this->drupalLogin($user);
......
......@@ -126,7 +126,7 @@ function testTranslatableFieldSaveLoad() {
field_test_entity_info_translatable($entity_type_id, TRUE);
$entity = entity_create($entity_type_id, array('type' => $this->instance->bundle));
$field_translations = array();
$available_langcodes = array_keys(language_list());
$available_langcodes = array_keys($this->container->get('language_manager')->getLanguages());
$entity->langcode->value = reset($available_langcodes);
foreach ($available_langcodes as $langcode) {
$field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getCardinality());
......
......@@ -103,7 +103,7 @@ function testFieldFormTranslationRevisions() {
// Prepare the field translations.
field_test_entity_info_translatable($this->entity_type, TRUE);
$entity = entity_create($this->entity_type);
$available_langcodes = array_flip(array_keys(language_list()));
$available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages()));
$field_name = $this->field->getName();
// Store the field translations.
......
......@@ -84,7 +84,7 @@ function testTextFormatCrud() {
*/
function verifyTextFormat($format) {
$t_args = array('%format' => $format->name);
$default_langcode = language_default()->id;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id;
// Verify the loaded filter has all properties.
$filter_format = entity_load('filter_format', $format->format);
......
......@@ -300,7 +300,7 @@ private function doAdminTests($user) {
'name' => 'Tags',
'description' => $description,
'vid' => 'tags',
'langcode' => language_default()->id,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id,
'help' => $help,
));
$vocabulary->save();
......
......@@ -42,7 +42,7 @@ function testForumUninstallWithField() {
// Create a taxonomy term.
$term = entity_create('taxonomy_term', array(
'name' => t('A term'),
'langcode' => language_default()->id,
'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id,
'description' => '',
'parent' => array(0),
'vid' => 'forums',
......
......@@ -12,7 +12,7 @@
* Prepare a language code list for unused predefined languages.
*/
function language_admin_predefined_list() {
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
$predefined = LanguageManager::getStandardLanguageList();
foreach ($predefined as $key => $value) {
if (isset($languages[$key])) {
......
......@@ -161,7 +161,7 @@ function language_process_language_select($element) {
// set the options.
if (!isset($element['#options'])) {
$element['#options'] = array();
foreach (language_list($element['#languages']) as $langcode => $language) {
foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) {
$element['#options'][$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
}
}
......@@ -203,12 +203,12 @@ function language_element_info() {
*/
function language_configuration_element_default_options() {
$language_options = array(
'site_default' => t("Site's default language (!language)", array('!language' => language_default()->name)),
'site_default' => t("Site's default language (!language)", array('!language' => \Drupal::languageManager()->getDefaultLanguage()->name)),
'current_interface' => t('Current interface language'),
'authors_default' => t("Author's preferred language"),
);
$languages = language_list(Language::STATE_ALL);
$languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL);
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
}
......@@ -383,7 +383,7 @@ function language_get_default_langcode($entity_type, $bundle) {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
switch ($configuration['langcode']) {
case 'site_default':
$default_value = language_default()->id;
$default_value = \Drupal::languageManager()->getDefaultLanguage()->id;
break;
case 'current_interface':
......@@ -457,7 +457,8 @@ function language_save($language) {
}
// Update URL Prefixes for all languages after the new default language is
// propagated and the language_list() cache is flushed.
// propagated and the LanguageManagerInterface::getLanguages() cache is
// flushed.
language_negotiation_url_prefixes_update();
// If after adding this language the site will become multilingual, we need to
......@@ -479,7 +480,7 @@ function language_save($language) {
* TRUE if language is successfully deleted. Otherwise FALSE.
*/
function language_delete($langcode) {
$languages = language_list(Language::STATE_ALL);
$languages = \Drupal::languageManager()->getLanguages(Language::STATE_ALL);
if (isset($languages[$langcode]) && !$languages[$langcode]->locked) {
$language = $languages[$langcode];
......@@ -551,7 +552,7 @@ function language_negotiation_url_prefixes() {
*/
function language_negotiation_url_prefixes_update() {
$prefixes = language_negotiation_url_prefixes();
foreach (language_list() as $language) {
foreach (\Drupal::languageManager()->getLanguages() as $language) {
// The prefix for this language should be updated if it's not assigned yet
// or the prefix is set to the empty string.
if (empty($prefixes[$language->id])) {
......@@ -679,8 +680,8 @@ function language_set_browser_drupal_langcode_mappings($mappings) {
* @see language_system_regional_settings_form_submit()
*/
function language_form_system_regional_settings_alter(&$form, &$form_state) {
$languages = language_list();
$default = language_default();
$languages = \Drupal::languageManager()->getLanguages();
$default = \Drupal::languageManager()->getDefaultLanguage();
foreach ($languages as $key => $language) {
$language_options[$key] = $language->name;
}
......@@ -702,7 +703,7 @@ function language_form_system_regional_settings_alter(&$form, &$form_state) {
* @see language_form_system_regional_settings_alter()
*/
function language_system_regional_settings_form_submit($form, &$form_state) {
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
$language = $languages[$form_state['values']['site_default_language']];
$language->default = TRUE;
language_save($language);
......
......@@ -51,7 +51,7 @@ protected function setUp() {
$this->installConfig(array('language'));
// Setup English.
language_save(language_default());
language_save(\Drupal::languageManager()->getDefaultLanguage());
// Setup Italian.
$language = new Language(array(
......@@ -70,7 +70,7 @@ protected function setUp() {
public function testConditions() {
// Grab the language condition and configure it to check the content
// language.
$language = language_load('en');
$language = \Drupal::languageManager()->getLanguage('en');
$condition = $this->manager->createInstance('language')
->setConfig('langcodes', array('en' => 'en', 'it' => 'it'))
->setContextValue('language', $language);
......@@ -91,7 +91,7 @@ public function testConditions() {
$this->assertEqual($condition->summary(), 'The language is not Italian.');
// Change the default language to Italian.
$language = language_load('it');
$language = \Drupal::languageManager()->getLanguage('it');
$condition = $this->manager->createInstance('language')
->setConfig('langcodes', array('en' => 'en', 'it' => 'it'))
......
......@@ -87,10 +87,10 @@ public function testDefaultLangcode() {
$this->assertEqual($langcode, $language_interface->id);
// Site's default.
$old_default = language_default();
$old_default = \Drupal::languageManager()->getDefaultLanguage();
$old_default->default = FALSE;
language_save($old_default);
$new_default = language_load('cc');
$new_default = \Drupal::languageManager()->getLanguage('cc');
$new_default->default = TRUE;
language_save($new_default);
language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'site_default', 'language_show' => TRUE));
......
......@@ -47,7 +47,7 @@ function testDependencyInjectedNewLanguage() {
* @see \Drupal\Core\Language\Language
*/
function testDependencyInjectedNewDefaultLanguage() {
$default_language = language_default();
$default_language = \Drupal::languageManager()->getDefaultLanguage();
// Change the language default object to different values.
$new_language_default = new Language(array(
'id' => 'fr',
......
......@@ -41,7 +41,7 @@ function testModuleInstallLanguageList() {
$edit['modules[Multilingual][language][enable]'] = 'language';
$this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
$this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using language_list() returns 1 language during Language installation.');
$this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using LanguageManager::getLanguages() returns 1 language during Language installation.');
// Get updated module list by rebuilding container.
$this->rebuildContainer();
......
......@@ -118,12 +118,12 @@ function testLanguageList() {
$this->assertResponse(404, 'Language no longer found.');
// Make sure the "language_count" state has been updated correctly.
$this->container->get('language_manager')->reset();
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// Delete French.
$this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete'));
// Get the count of languages.
$this->container->get('language_manager')->reset();
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// We need raw here because %language and %langcode will add HTML.
$t_args = array('%language' => 'French', '%langcode' => 'fr');
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), 'Disabled language has been removed.');
......@@ -179,13 +179,13 @@ function testLanguageStates() {
$expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx');
$expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en');
$locked_languages = language_list(Language::STATE_LOCKED);
$locked_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_LOCKED);
$this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.');
$all_languages = language_list(Language::STATE_ALL);
$all_languages = $this->container->get('language_manager')->getLanguages(Language::STATE_ALL);
$this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.');
$conf_languages = language_list();
$conf_languages = $this->container->get('language_manager')->getLanguages();
$this->assertEqual(array_diff_key($expected_conf_languages, $conf_languages), array(), 'Configurable languages loaded correctly.');
}
}
......@@ -57,7 +57,7 @@ function setUp() {
// Verify that French is the only language.
$this->container->get('language_manager')->reset();
$this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual');
$this->assertEqual(language_default()->id, 'fr', 'French is the default language');
$this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'fr', 'French is the default language');
// Set language detection to URL.
$edit = array('language_interface[enabled][language-url]' => TRUE);
......
......@@ -98,7 +98,7 @@ function testUILanguageNegotiation() {
// into database when seen by t(). Without doing this, our target string
// is for some reason not found when doing translate search. This might
// be some bug.
$default_language = language_default();
$default_language = \Drupal::languageManager()->getDefaultLanguage();
$language = new Language(array(
'id' => $langcode_browser_fallback,
'default' => TRUE,
......@@ -364,7 +364,7 @@ function testUrlLanguageFallback() {
'id' => $langcode_browser_fallback,
));
language_save($language);
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// Enable the path prefix for the default language: this way any unprefixed
// URL must have a valid fallback value.
......@@ -416,7 +416,7 @@ function testLanguageDomain() {
'id' => $langcode,
));
language_save($language);
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// Enable browser and URL language detection.
$edit = array(
......
......@@ -54,7 +54,7 @@ function setUp() {
*/
function testUrlRewritingEdgeCases() {
// Check URL rewriting with a non-installed language.
$non_existing = language_default();
$non_existing = \Drupal::languageManager()->getDefaultLanguage();
$non_existing->id = $this->randomName();
$this->checkUrl($non_existing, 'Path language is ignored if language is not installed.', 'URL language negotiation does not work with non-installed languages');
......@@ -129,7 +129,7 @@ function testDomainNameNegotiationPort() {
$request = $this->prepareRequestForGenerator(TRUE, array('HTTP_HOST' => $server['HTTP_HOST'] . ':88'));
// Create an absolute French link.
$language = language_load('fr');
$language = \Drupal::languageManager()->getLanguage('fr');
$url = url('', array(
'absolute' => TRUE,
'language' => $language,
......
......@@ -98,5 +98,5 @@ function language_test_language_fallback_candidates_test_alter(array &$candidate
* Implements hook_module_preinstall().
*/
function language_test_module_preinstall() {
\Drupal::state()->set('language_test.language_count_preinstall', count(language_list()));
\Drupal::state()->set('language_test.language_count_preinstall', count(\Drupal::languageManager()->getLanguages()));
}
......@@ -8,6 +8,7 @@
namespace Drupal\language_test\Controller;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Language\LanguageManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
......@@ -24,21 +25,29 @@ class LanguageTestController implements ContainerInjectionInterface {
*/
protected $httpKernel;
/**
* The language manager service.
*
* @var \Drupal\Core\Language\LanguageManager
*/
protected $languageManager;
/**
* Constructs a new LanguageTestController object.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel
* An HTTP kernel.
*/
public function __construct(HttpKernelInterface $httpKernel) {
public function __construct(HttpKernelInterface $httpKernel, LanguageManager $language_manager) {
$this->httpKernel = $httpKernel;
$this->languageManager = $language_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('http_kernel'));
return new static($container->get('http_kernel'), $container->get('language_manager'));
}
/**
......@@ -48,7 +57,7 @@ public static function create(ContainerInterface $container) {
*/
public function typeLinkActiveClass() {
// We assume that 'en' and 'fr' have been configured.
$languages = language_list();
$languages = $this->languageManager->getLanguages();
return array(
'no_language' => array(
'#type' => 'link',
......
......@@ -195,7 +195,7 @@ function buildSourceString($values = array()) {
*/
function createAllTranslations($source, $values = array()) {
$list = array();
foreach (language_list() as $language) {
foreach ($this->container->get('language_manager')->getLanguages() as $language) {
$list[$language->id] = $this->createTranslation($source, $language->id, $values);
}
return $list;
......
......@@ -81,7 +81,7 @@ protected function addLanguage($langcode) {
$edit = array('predefined_langcode' => $langcode);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
$this->container->get('language_manager')->reset();
$this->assertTrue(language_load($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode)));
$this->assertTrue(\Drupal::languageManager()->getLanguage($langcode), String::format('Language %langcode added.', array('%langcode' => $langcode)));
}
/**
......
......@@ -20,7 +20,7 @@
*/
function locale_translate_import_form($form, &$form_state) {
Drupal::languageManager()->reset();
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
// Initialize a language list to the ones available, including English if we
// are to translate Drupal to English as well.
......@@ -118,7 +118,7 @@ function locale_translate_import_form_submit($form, &$form_state) {
if ($file = file_save_upload('file', $form_state, $form['file']['#upload_validators'], 'translations://', 0)) {
// Add language, if not yet supported.
$language = language_load($form_state['values']['langcode']);
$language = \Drupal::languageManager()->getLanguage($form_state['values']['langcode']);
if (empty($language)) {
$language = new Language(array(
'id' => $form_state['values']['langcode']
......@@ -182,7 +182,7 @@ function locale_translate_batch_import_files($options, $force = FALSE) {
else {
// If langcode was not provided, make sure to only import files for the
// languages we have enabled.
$langcodes = array_keys(language_list());
$langcodes = array_keys(\Drupal::languageManager()->getLanguages());
}
$files = locale_translate_get_interface_translation_files(array(), $langcodes);
......
......@@ -269,7 +269,7 @@ function locale_language_entity_delete(LanguageEntity $language) {
* unless it is marked as translatable.
*/
function locale_translatable_language_list() {
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
if (!locale_translate_english()) {
unset($languages['en']);
}
......@@ -1252,7 +1252,7 @@ function _locale_rebuild_js($langcode = NULL) {
}
else {
// Get information about the locale.
$languages = language_list();
$languages = \Drupal::languageManager()->getLanguages();
$language = $languages[$langcode];
}
......
......@@ -114,7 +114,7 @@ protected function getFormSubmitAction(EntityInterface $entity, $langcode) {
protected function doTestPublishedStatus() {
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$path = $entity->getSystemPath('edit-form');
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
$actions = array(
t('Save and keep published'),
......@@ -145,7 +145,7 @@ protected function doTestPublishedStatus() {
protected function doTestAuthoringInfo() {
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$path = $entity->getSystemPath('edit-form');
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
$values = array();
// Post different base field information for each translation.
......@@ -331,7 +331,7 @@ function testTranslationRendering() {
* The translation values to be found.
*/
protected function doTestTranslations($path, array $values) {
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
foreach ($this->langcodes as $langcode) {
$this->drupalGet($path, array('language' => $languages[$langcode]));
$this->assertText($values[$langcode]['title'][0]['value'], format_string('The %langcode node translation is correctly displayed.', array('%langcode' => $langcode)));
......
......@@ -90,7 +90,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
$url_options = array('absolute' => TRUE);
if (isset($options['langcode'])) {
$url_options['language'] = language_load($options['langcode']);
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
}
else {
......
......@@ -107,7 +107,7 @@ function testAliasTranslation() {
// Languages are cached on many levels, and we need to clear those caches.
$this->container->get('language_manager')->reset();
$this->rebuildContainer();
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
// Ensure the node was created.
$english_node = node_load($english_node->id(), TRUE);
......@@ -121,7 +121,7 @@ function testAliasTranslation() {
// Confirm that the alias is returned by url(). Languages are cached on
// many levels, and we need to clear those caches.
$this->container->get('language_manager')->reset();
$languages = language_list();
$languages = $this->container->get('language_manager')->getLanguages();
$url