Skip to content

Commit

Permalink
Revert "Issue #2457653 by Gábor Hojtsy: System.site langcode is both …
Browse files Browse the repository at this point in the history
…used as a file language code and a site language code"

This reverts commit 364a6e9.
  • Loading branch information
Nathaniel Catchpole committed Mar 25, 2015
1 parent 6ee9b6e commit 600d79f
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 29 deletions.
5 changes: 1 addition & 4 deletions includes/install.core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1664,10 +1664,7 @@ function install_download_additional_translations_operations(&$install_state) {
// If a non-English language was selected, change the default language and
// remove English.
if ($langcode != 'en') {
\Drupal::configFactory()->getEditable('system.site')
->set('langcode', $langcode)
->set('default_langcode', $langcode)
->save();
\Drupal::configFactory()->getEditable('system.site')->set('langcode', $langcode)->save();
\Drupal::service('language.default')->set($language);
if (empty($install_state['profile_info']['keep_english'])) {
entity_delete_multiple('configurable_language', array('en'));
Expand Down
1 change: 0 additions & 1 deletion includes/install.inc
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,6 @@ function drupal_install_system($install_state) {
if (isset($install_state['parameters']['langcode'])) {
\Drupal::configFactory()->getEditable('system.site')
->set('langcode', $install_state['parameters']['langcode'])
->set('default_langcode', $install_state['parameters']['langcode'])
->save();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function testPerUserLoginFloodControl() {
*/
function testLocale() {
ConfigurableLanguage::createFromLangcode('de')->save();
$this->config('system.site')->set('default_langcode', 'de')->save();
$this->config('system.site')->set('langcode', 'de')->save();

$account = $this->drupalCreateUser();
$url = Url::fromRoute('router_test.11');
Expand Down
2 changes: 1 addition & 1 deletion modules/ckeditor/src/Tests/CKEditorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ function testJSTranslation() {
protected function assertCKEditorLanguage($langcode = 'fr') {
// Set French as the site default language.
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('default_langcode', 'fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save();

// Reset the language manager so new negotiations attempts will fall back on
// French. Reinject the language manager CKEditor to use the current one.
Expand Down
2 changes: 1 addition & 1 deletion modules/config/src/Tests/ConfigLanguageOverrideWebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function testSiteNameTranslation() {
// overrides still work.
$language_manager = \Drupal::languageManager()->reset();
$this->assertTrue($language_manager->isMultilingual(), 'The test site is multilingual.');
$this->config('system.site')->set('default_langcode', 'xx')->save();
$this->config('system.site')->set('langcode', 'xx')->save();

ConfigurableLanguage::load('en')->delete();
$this->assertFalse($language_manager->isMultilingual(), 'The test site is monolingual.');
Expand Down
4 changes: 2 additions & 2 deletions modules/language/src/EventSubscriber/ConfigSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function __construct(LanguageManagerInterface $language_manager, Language
*/
public function onConfigSave(ConfigCrudEvent $event) {
$saved_config = $event->getConfig();
if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) {
$language = $this->languageManager->getLanguage($saved_config->get('default_langcode'));
if ($saved_config->getName() == 'system.site' && $event->isChanged('langcode')) {
$language = $this->languageManager->getLanguage($saved_config->get('langcode'));
// During an import the language might not exist yet.
if ($language) {
$this->languageDefault->set($language);
Expand Down
2 changes: 1 addition & 1 deletion modules/language/src/LanguageListBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// Save the default language if changed.
$new_id = $form_state->getValue('site_default_language');
if ($new_id != $this->languageManager->getDefaultLanguage()->getId()) {
$this->configFactory->getEditable('system.site')->set('default_langcode', $new_id)->save();
$this->configFactory->getEditable('system.site')->set('langcode', $new_id)->save();
$this->languageManager->reset();
}

Expand Down
2 changes: 1 addition & 1 deletion modules/language/src/LanguageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function isMultilingual() {
protected function getDefaultLanguageValues() {
$config_storage = BootstrapConfigStorageFactory::get();
$system = $config_storage->read('system.site');
$default_language = $config_storage->read(static::CONFIG_PREFIX . $system['default_langcode']);
$default_language = $config_storage->read(static::CONFIG_PREFIX . $system['langcode']);
if (is_array($default_language)) {
return $default_language;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function testDefaultLangcode() {
$configurable_language = entity_load('configurable_language', $old_default->getId());
$this->assertTrue($configurable_language->isDefault(), 'The en language entity is flagged as the default language.');

$this->config('system.site')->set('default_langcode', 'cc')->save();
$this->config('system.site')->set('langcode', 'cc')->save();
ContentLanguageSettings::loadByEntityTypeBundle('entity_test','custom_bundle')
->setLanguageAlterable(TRUE)
->setDefaultLangcode(LanguageInterface::LANGCODE_SITE_DEFAULT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function testDependencyInjectedNewDefaultLanguage() {
$default_language = ConfigurableLanguage::load(\Drupal::languageManager()->getDefaultLanguage()->getId());
// Change the language default object to different values.
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('default_langcode', 'fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save();

// The language system creates a Language object which contains the
// same properties as the new default language object.
Expand All @@ -60,7 +60,7 @@ function testDependencyInjectedNewDefaultLanguage() {
}

// Re-save the previous default language and the delete should work.
$this->config('system.site')->set('default_langcode', $default_language->getId())->save();
$this->config('system.site')->set('langcode', $default_language->getId())->save();

entity_delete_multiple('configurable_language', array('fr'));
$result = \Drupal::languageManager()->getCurrentLanguage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function testUILanguageNegotiation() {
// be some bug.
$default_language = \Drupal::languageManager()->getDefaultLanguage();
ConfigurableLanguage::createFromLangcode($langcode_browser_fallback)->save();
$this->config('system.site')->set('default_langcode', $langcode_browser_fallback)->save();
$this->config('system.site')->set('langcode', $langcode_browser_fallback)->save();
ConfigurableLanguage::createFromLangcode($langcode)->save();

// We will look for this string in the admin/config screen to see if the
Expand All @@ -106,7 +106,7 @@ function testUILanguageNegotiation() {
// Now the t()'ed string is in db so switch the language back to default.
// This will rebuild the container so we need to rebuild the container in
// the test environment.
$this->config('system.site')->set('default_langcode', $default_language->getId())->save();
$this->config('system.site')->set('langcode', $default_language->getId())->save();
$this->config('language.negotiation')->set('url.prefixes.en', '')->save();
$this->rebuildContainer();

Expand Down
2 changes: 1 addition & 1 deletion modules/locale/src/Tests/LocaleLocaleLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function setUp() {

// Change the language default object to different values.
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('default_langcode', 'fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save();

$this->drupalLogin($this->rootUser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LocaleTranslatedSchemaDefinitionTest extends WebTestBase {
protected function setUp() {
parent::setUp();
ConfigurableLanguage::createFromLangcode('fr')->save();
$this->config('system.site')->set('default_langcode', 'fr')->save();
$this->config('system.site')->set('langcode', 'fr')->save();
// Make sure new entity type definitions are processed.
\Drupal::service('entity.definition_update_manager')->applyUpdates();
// Clear all caches so that the base field definition, its cache in the
Expand Down
2 changes: 1 addition & 1 deletion modules/menu_ui/src/Tests/MenuLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function testMenuLanguageRemovedEnglish() {

// Remove English language. To do that another language has to be set as
// default.
$this->config('system.site')->set('default_langcode', 'cs')->save();
$this->config('system.site')->set('langcode', 'cs')->save();
entity_delete_multiple('configurable_language', array('en'));

// Save the menu again and check if the language is still the same.
Expand Down
1 change: 0 additions & 1 deletion modules/system/config/install/system.site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ page:
admin_compact_mode: false
weight_select_max: 100
langcode: en
default_langcode: en
5 changes: 1 addition & 4 deletions modules/system/config/schema/system.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ system.site:
label: 'Weight element maximum value'
langcode:
type: string
label: 'Language code'
default_langcode:
type: string
label: 'Site default language code'
label: 'Default language'
mail_notification:
type: string
label: 'Notification email address'
Expand Down
2 changes: 1 addition & 1 deletion modules/system/src/Tests/Common/FormatDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function testFormatDate() {
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');

// Change the default language and timezone.
$this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
$this->config('system.site')->set('langcode', static::LANGCODE)->save();
date_default_timezone_set('America/Los_Angeles');

$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
Expand Down
2 changes: 1 addition & 1 deletion modules/system/src/Tests/Theme/TwigTransTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function setUp() {
$this->installLanguages();

// Assign Lolspeak (xx) to be the default language.
$this->config('system.site')->set('default_langcode', 'xx')->save();
$this->config('system.site')->set('langcode', 'xx')->save();
$this->rebuildContainer();

// Check that lolspeak is the default language for the site.
Expand Down
2 changes: 1 addition & 1 deletion modules/taxonomy/src/Tests/TermLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function testDefaultTermLanguage() {

// Change the default language of the site and check if the default terms
// language is still correctly selected.
$this->config('system.site')->set('default_langcode', 'cc')->save();
$this->config('system.site')->set('langcode', 'cc')->save();
$edit = array(
'default_language[langcode]' => LanguageInterface::LANGCODE_SITE_DEFAULT,
'default_language[language_alterable]' => TRUE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testCreateView() {

// Add a new language and mark it as default.
ConfigurableLanguage::createFromLangcode('it')->save();
$this->config('system.site')->set('default_langcode', 'it')->save();
$this->config('system.site')->set('langcode', 'it')->save();

$form_state->setValues([
'id' => $random_id,
Expand Down

0 comments on commit 600d79f

Please sign in to comment.