Commit 848dbc55 authored by catch's avatar catch

Issue #2341341 by YesCT, martin107, vijaycs85, fran seva: Change public 'name'...

Issue #2341341 by YesCT, martin107, vijaycs85, fran seva: Change public 'name' property access on languages to getName() and add back setName().
parent 6cbb5d9e
...@@ -744,9 +744,9 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { ...@@ -744,9 +744,9 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Add the site's default language if flagged as allowed value. // Add the site's default language if flagged as allowed value.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
$default = isset($default) ? $default : \Drupal::languageManager()->getDefaultLanguage(); $default = \Drupal::languageManager()->getDefaultLanguage();
// Rename the default language. // Rename the default language.
$default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); $default->setName(t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default; $filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
} }
......
...@@ -34,7 +34,7 @@ class Language implements LanguageInterface { ...@@ -34,7 +34,7 @@ class Language implements LanguageInterface {
* *
* @var string * @var string
*/ */
public $name = ''; protected $name = '';
/** /**
* The ID, langcode. * The ID, langcode.
...@@ -103,6 +103,15 @@ public function getName() { ...@@ -103,6 +103,15 @@ public function getName() {
return $this->name; return $this->name;
} }
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -109,6 +109,16 @@ interface LanguageInterface { ...@@ -109,6 +109,16 @@ interface LanguageInterface {
*/ */
public function getName(); public function getName();
/**
* Sets the name of the language.
*
* @param string $name
* The human-readable English name of the language.
*
* @return $this
*/
public function setName($name);
/** /**
* Gets the ID (language code). * Gets the ID (language code).
* *
......
...@@ -146,11 +146,9 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { ...@@ -146,11 +146,9 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) {
// Add the site's default language if flagged as allowed value. // Add the site's default language if flagged as allowed value.
if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { if ($flags & LanguageInterface::STATE_SITE_DEFAULT) {
$default = isset($default) ? $default : $this->getDefaultLanguage(); // Setup a language to have the defaults, but with overridden name.
// Rename the default language. But we do not want to do this globally, $default = $this->getDefaultLanguage();
// if we're acting on a global object, so clone the object first. $default->setName($this->t("Site's default language (@lang_name)", array('@lang_name' => $default->getName())));
$default = clone $default;
$default->name = $this->t("Site's default language (@lang_name)", array('@lang_name' => $default->name));
$filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default; $filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default;
} }
...@@ -187,7 +185,7 @@ public function getLanguageName($langcode) { ...@@ -187,7 +185,7 @@ public function getLanguageName($langcode) {
return $this->t('None'); return $this->t('None');
} }
if ($language = $this->getLanguage($langcode)) { if ($language = $this->getLanguage($langcode)) {
return $language->name; return $language->getName();
} }
if (empty($langcode)) { if (empty($langcode)) {
return $this->t('Unknown'); return $this->t('Unknown');
......
...@@ -77,7 +77,7 @@ public function setValue($value, $notify = TRUE) { ...@@ -77,7 +77,7 @@ public function setValue($value, $notify = TRUE) {
*/ */
public function getString() { public function getString() {
$language = $this->getValue(); $language = $this->getValue();
return $language ? $language->name : ''; return $language ? $language->getName() : '';
} }
/** /**
......
...@@ -164,7 +164,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl ...@@ -164,7 +164,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl
// Prepare the language name and the operations depending on whether this // Prepare the language name and the operations depending on whether this
// is the original language or not. // is the original language or not.
if ($langcode == $original_langcode) { if ($langcode == $original_langcode) {
$language_name = '<strong>' . $this->t('@language (original)', array('@language' => $language->name)) . '</strong>'; $language_name = '<strong>' . $this->t('@language (original)', array('@language' => $language->getName())) . '</strong>';
// Check access for the path/route for editing, so we can decide to // Check access for the path/route for editing, so we can decide to
// include a link to edit or not. // include a link to edit or not.
...@@ -180,7 +180,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl ...@@ -180,7 +180,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl
} }
} }
else { else {
$language_name = $language->name; $language_name = $language->getName();
$operations = array(); $operations = array();
// If no translation exists for this language, link to add one. // If no translation exists for this language, link to add one.
......
...@@ -29,7 +29,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ ...@@ -29,7 +29,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
$form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode);
$form['#title'] = $this->t('Add @language translation for %label', array( $form['#title'] = $this->t('Add @language translation for %label', array(
'%label' => $this->mapper->getTitle(), '%label' => $this->mapper->getTitle(),
'@language' => $this->language->name, '@language' => $this->language->getName(),
)); ));
return $form; return $form;
} }
...@@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ ...@@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->name))); drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->getName())));
} }
} }
...@@ -89,7 +89,7 @@ public static function create(ContainerInterface $container) { ...@@ -89,7 +89,7 @@ public static function create(ContainerInterface $container) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuestion() { public function getQuestion() {
return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name)); return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()));
} }
/** /**
...@@ -145,7 +145,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ...@@ -145,7 +145,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$cache_backend->deleteAll(); $cache_backend->deleteAll();
} }
drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name))); drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName())));
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirectUrl($this->getCancelUrl());
} }
......
...@@ -29,7 +29,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ ...@@ -29,7 +29,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
$form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode); $form = parent::buildForm($form, $form_state, $request, $plugin_id, $langcode);
$form['#title'] = $this->t('Edit @language translation for %label', array( $form['#title'] = $this->t('Edit @language translation for %label', array(
'%label' => $this->mapper->getTitle(), '%label' => $this->mapper->getTitle(),
'@language' => $this->language->name, '@language' => $this->language->getName(),
)); ));
return $form; return $form;
} }
...@@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ ...@@ -39,7 +39,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->name))); drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->getName())));
} }
} }
...@@ -316,7 +316,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d ...@@ -316,7 +316,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d
'!label <span class="visually-hidden">(!source_language)</span>', '!label <span class="visually-hidden">(!source_language)</span>',
array( array(
'!label' => $this->t($definition['label']), '!label' => $this->t($definition['label']),
'!source_language' => $this->sourceLanguage->name, '!source_language' => $this->sourceLanguage->getName(),
) )
), ),
'#type' => 'item', '#type' => 'item',
......
...@@ -29,7 +29,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte ...@@ -29,7 +29,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte
$format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $value))); $format = $this->t('Displayed as %date_format', array('%date_format' => \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', $value)));
return array( return array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->getName() . ')</span>',
'#description' => $description, '#description' => $description,
'#default_value' => $value, '#default_value' => $value,
'#attributes' => array('lang' => $language->getId()), '#attributes' => array('lang' => $language->getId()),
......
...@@ -29,7 +29,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte ...@@ -29,7 +29,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte
return array( return array(
'#type' => 'textarea', '#type' => 'textarea',
'#default_value' => $value, '#default_value' => $value,
'#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->getName() . ')</span>',
'#rows' => $rows, '#rows' => $rows,
'#attributes' => array('lang' => $language->getId()), '#attributes' => array('lang' => $language->getId()),
); );
......
...@@ -24,7 +24,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte ...@@ -24,7 +24,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte
return array( return array(
'#type' => 'textfield', '#type' => 'textfield',
'#default_value' => $value, '#default_value' => $value,
'#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->name . ')</span>', '#title' => $this->t($definition->getLabel()) . '<span class="visually-hidden"> (' . $language->getName() . ')</span>',
'#attributes' => array('lang' => $language->getId()), '#attributes' => array('lang' => $language->getId()),
); );
} }
......
...@@ -325,7 +325,7 @@ public function testContactConfigEntityTranslation() { ...@@ -325,7 +325,7 @@ public function testContactConfigEntityTranslation() {
// Test that delete links work and operations perform properly. // Test that delete links work and operations perform properly.
foreach ($this->langcodes as $langcode) { foreach ($this->langcodes as $langcode) {
$replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->name); $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->getName());
$this->drupalGet("$translation_base_url/$langcode/delete"); $this->drupalGet("$translation_base_url/$langcode/delete");
$this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
......
...@@ -269,7 +269,7 @@ function content_translation_form_language_content_settings_validate(array $form ...@@ -269,7 +269,7 @@ function content_translation_form_language_content_settings_validate(array $form
$values = $bundle_settings['settings']['language']; $values = $bundle_settings['settings']['language'];
if (empty($values['language_show']) && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { if (empty($values['language_show']) && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) {
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) { foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name; $locked_languages[] = $language->getName();
} }
$form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages)))); $form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
} }
......
...@@ -677,7 +677,7 @@ function content_translation_language_configuration_element_validate($element, F ...@@ -677,7 +677,7 @@ function content_translation_language_configuration_element_validate($element, F
$values = $form_state->getValue($key); $values = $form_state->getValue($key);
if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) { if (!$values['language_show'] && $values['content_translation'] && \Drupal::languageManager()->isLanguageLocked($values['langcode'])) {
foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) { foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name; $locked_languages[] = $language->getName();
} }
// @todo Set the correct form element name as soon as the element parents // @todo Set the correct form element name as soon as the element parents
// are correctly set. We should be using NestedArray::getValue() but for // are correctly set. We should be using NestedArray::getValue() but for
......
...@@ -109,7 +109,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ...@@ -109,7 +109,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
$title = $this->entityFormTitle($entity); $title = $this->entityFormTitle($entity);
// When editing the original values display just the entity label. // When editing the original values display just the entity label.
if ($form_langcode != $entity_langcode) { if ($form_langcode != $entity_langcode) {
$t_args = array('%language' => $languages[$form_langcode]->name, '%title' => $entity->label()); $t_args = array('%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label());
$title = empty($source_langcode) ? $title . ' [' . t('%language translation', $t_args) . ']' : t('Create %language translation of %title', $t_args); $title = empty($source_langcode) ? $title . ' [' . t('%language translation', $t_args) . ']' : t('Create %language translation of %title', $t_args);
} }
$form['#title'] = $title; $form['#title'] = $title;
...@@ -120,7 +120,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ...@@ -120,7 +120,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
if ($has_translations && $new_translation) { if ($has_translations && $new_translation) {
$form['source_langcode'] = array( $form['source_langcode'] = array(
'#type' => 'details', '#type' => 'details',
'#title' => t('Source language: @language', array('@language' => $languages[$source_langcode]->name)), '#title' => t('Source language: @language', array('@language' => $languages[$source_langcode]->getName())),
'#tree' => TRUE, '#tree' => TRUE,
'#weight' => -100, '#weight' => -100,
'#multilingual' => TRUE, '#multilingual' => TRUE,
...@@ -139,7 +139,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ...@@ -139,7 +139,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
); );
foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) {
if (isset($translations[$language->getId()])) { if (isset($translations[$language->getId()])) {
$form['source_langcode']['source']['#options'][$language->getId()] = $language->name; $form['source_langcode']['source']['#options'][$language->getId()] = $language->getName();
} }
} }
} }
...@@ -152,7 +152,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ...@@ -152,7 +152,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En
$form['langcode']['#options'] = array(); $form['langcode']['#options'] = array();
foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) {
if (empty($translations[$language->getId()]) || $language->getId() == $entity_langcode) { if (empty($translations[$language->getId()]) || $language->getId() == $entity_langcode) {
$form['langcode']['#options'][$language->getId()] = $language->name; $form['langcode']['#options'][$language->getId()] = $language->getName();
} }
} }
} }
...@@ -450,7 +450,7 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) { ...@@ -450,7 +450,7 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) {
'target' => $form_object->getFormLangcode($form_state), 'target' => $form_object->getFormLangcode($form_state),
)); ));
$languages = language_list(); $languages = language_list();
drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name))); drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->getName())));
} }
/** /**
......
...@@ -75,7 +75,7 @@ public function overview(Request $request, $entity_type_id = NULL) { ...@@ -75,7 +75,7 @@ public function overview(Request $request, $entity_type_id = NULL) {
$show_source_column = !empty($additional_source_langcodes); $show_source_column = !empty($additional_source_langcodes);
foreach ($languages as $language) { foreach ($languages as $language) {
$language_name = $language->name; $language_name = $language->getName();
$langcode = $language->getId(); $langcode = $language->getId();
$add_url = new Url( $add_url = new Url(
...@@ -161,7 +161,7 @@ public function overview(Request $request, $entity_type_id = NULL) { ...@@ -161,7 +161,7 @@ public function overview(Request $request, $entity_type_id = NULL) {
$source_name = $this->t('n/a'); $source_name = $this->t('n/a');
} }
else { else {
$source_name = isset($languages[$source]) ? $languages[$source]->name : $this->t('n/a'); $source_name = isset($languages[$source]) ? $languages[$source]->getName() : $this->t('n/a');
if ($handler->getTranslationAccess($entity, 'delete')->isAllowed()) { if ($handler->getTranslationAccess($entity, 'delete')->isAllowed()) {
$links['delete'] = array( $links['delete'] = array(
'title' => $this->t('Delete'), 'title' => $this->t('Delete'),
......
...@@ -57,7 +57,7 @@ public function getConfirmText() { ...@@ -57,7 +57,7 @@ public function getConfirmText() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getQuestion() { public function getQuestion() {
return $this->t('Are you sure you want to delete the @language translation of %label?', array('@language' => $this->language->name, '%label' => $this->entity->label())); return $this->t('Are you sure you want to delete the @language translation of %label?', array('@language' => $this->language->getName(), '%label' => $this->entity->label()));
} }
/** /**
......
...@@ -149,7 +149,7 @@ function language_process_language_select($element) { ...@@ -149,7 +149,7 @@ function language_process_language_select($element) {
if (!isset($element['#options'])) { if (!isset($element['#options'])) {
$element['#options'] = array(); $element['#options'] = array();
foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) { foreach (\Drupal::languageManager()->getLanguages($element['#languages']) as $langcode => $language) {
$element['#options'][$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->name)) : $language->name; $element['#options'][$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
} }
} }
// Add "Built-in English" language to the select when the default value is // Add "Built-in English" language to the select when the default value is
...@@ -490,7 +490,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface ...@@ -490,7 +490,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface
$languages = \Drupal::languageManager()->getLanguages(); $languages = \Drupal::languageManager()->getLanguages();
$default = \Drupal::languageManager()->getDefaultLanguage(); $default = \Drupal::languageManager()->getDefaultLanguage();
foreach ($languages as $key => $language) { foreach ($languages as $key => $language) {
$language_options[$key] = $language->name; $language_options[$key] = $language->getName();
} }
$form['locale']['site_default_language'] = array( $form['locale']['site_default_language'] = array(
'#type' => 'select', '#type' => 'select',
......
...@@ -92,14 +92,14 @@ public static function processLanguageConfiguration(&$element, FormStateInterfac ...@@ -92,14 +92,14 @@ public static function processLanguageConfiguration(&$element, FormStateInterfac
*/ */
protected static function getDefaultOptions() { protected static function getDefaultOptions() {
$language_options = array( $language_options = array(
LanguageInterface::LANGCODE_SITE_DEFAULT => t("Site's default language (!language)", array('!language' => static::languageManager()->getDefaultLanguage()->name)), LanguageInterface::LANGCODE_SITE_DEFAULT => t("Site's default language (!language)", array('!language' => static::languageManager()->getDefaultLanguage()->getName())),
'current_interface' => t('Current interface language'), 'current_interface' => t('Current interface language'),
'authors_default' => t("Author's preferred language"), 'authors_default' => t("Author's preferred language"),
); );
$languages = static::languageManager()->getLanguages(LanguageInterface::STATE_ALL); $languages = static::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
foreach ($languages as $langcode => $language) { foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->name)) : $language->name; $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
} }
return $language_options; return $language_options;
......
...@@ -200,6 +200,15 @@ public function getName() { ...@@ -200,6 +200,15 @@ public function getName() {
return $this->label(); return $this->label();
} }
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->label = $name;
return $this;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -118,7 +118,7 @@ public function validateCustom(array $form, FormStateInterface $form_state) { ...@@ -118,7 +118,7 @@ public function validateCustom(array $form, FormStateInterface $form_state) {
$this->validateCommon($form['custom_language'], $form_state); $this->validateCommon($form['custom_language'], $form_state);
if ($language = language_load($langcode)) { if ($language = language_load($langcode)) {
$form_state->setErrorByName('langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->name, '%langcode' => $langcode))); $form_state->setErrorByName('langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode)));
} }
} }
else { else {
...@@ -136,7 +136,7 @@ public function validatePredefined($form, FormStateInterface $form_state) { ...@@ -136,7 +136,7 @@ public function validatePredefined($form, FormStateInterface $form_state) {
} }
else { else {
if ($language = language_load($langcode)) { if ($language = language_load($langcode)) {
$form_state->setErrorByName('predefined_langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->name, '%langcode' => $langcode))); $form_state->setErrorByName('predefined_langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode)));
} }
} }
} }
......