Commit fbec9433 authored by alexpott's avatar alexpott

Issue #2031197 by webflo, kfritsche, penyaskito: Language configuration...

Issue #2031197 by webflo, kfritsche, penyaskito: Language configuration entities should be created in English at all times.
parent e29aaabd
......@@ -187,7 +187,7 @@ function _language_admin_common_controls(&$form, $language = NULL) {
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Language name'),
'#title' => t('Language name in English'),
'#maxlength' => 64,
'#default_value' => @$language->name,
'#required' => TRUE,
......
......@@ -10,6 +10,8 @@
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Language\LanguageManager;
use Drupal\language\LanguageInterface;
/**
......@@ -76,4 +78,15 @@ class Language extends ConfigEntityBase implements LanguageInterface {
*/
public $locked = FALSE;
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageControllerInterface $storage_controller) {
parent::preSave($storage_controller);
// Languages are picked from a predefined list which is given in English.
// For the uncommon case of custom languages the label should be given in
// English.
$this->langcode = 'en';
}
}
......@@ -51,6 +51,9 @@ function testLanguageConfiguration() {
$this->drupalPost('admin/config/regional/language/add', $edit, 'Add language');
$this->assertText('French');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Langcode for Languages is always 'en'.
$language = $this->container->get('config.factory')->get('language.entity.fr')->get();
$this->assertEqual($language['langcode'], 'en');
// Check if the Default English language has no path prefix.
$this->drupalGet('admin/config/regional/language/detection/url');
......@@ -100,6 +103,16 @@ function testLanguageConfiguration() {
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertText(t('The prefix may not contain a slash.'), 'English prefix cannot be changed to contain a slash.');
// Remove English language and add a new Language to check if langcode of
// Language entity is 'en'.
$this->assert(language_delete('en'), 'Deleted English language.');
$edit = array(
'predefined_langcode' => 'de',
);
$this->drupalPost('admin/config/regional/language/add', $edit, 'Add language');
$language = $this->container->get('config.factory')->get('language.entity.de')->get();
$this->assertEqual($language['langcode'], 'en');
}
/**
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\language\Tests\LanguageCustomConfigurationTest.
* Contains \Drupal\language\Tests\LanguageCustomConfigurationTest.
*/
namespace Drupal\language\Tests;
......@@ -47,7 +47,7 @@ public function testLanguageConfiguration() {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Test validation on missing values.
$this->assertText(t('!name field is required.', array('!name' => t('Language code'))));
$this->assertText(t('!name field is required.', array('!name' => t('Language name'))));
$this->assertText(t('!name field is required.', array('!name' => t('Language name in English'))));
$empty_language = new Language();
$this->assertFieldChecked('edit-direction-' . $empty_language->direction, 'Consistent usage of language direction.');
$this->assertEqual($this->getUrl(), url('admin/config/regional/language/add', array('absolute' => TRUE)), 'Correct page redirection.');
......@@ -61,7 +61,7 @@ public function testLanguageConfiguration() {
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertRaw(t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => t('Language code'))));
$this->assertRaw(t('%field cannot contain any markup.', array('%field' => t('Language name'))));
$this->assertRaw(t('%field cannot contain any markup.', array('%field' => t('Language name in English'))));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language/add', array('absolute' => TRUE)), 'Correct page redirection.');
// Test validation of existing language values.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment