Problem/Motivation

When a language is removed the content that was created in that language loses it's field content.

Steps to reproduce

  1. Install Drupal in English
  2. Create an English article with some body text.
  3. Enable the Language module
  4. Add a language, make it the default language (admin/config/regional/language).
  5. Remove the English language.
  6. Go to the English article and notice that the body text is gone.
  7. Edit the English article and notice that the body field is empty.

A quick investigation showed that the language code in the field__body and the node tables are, after deleting English, still at 'en'. The confirmation message in step 5 says "Deleting a language will ... and content in this language will be set to be language neutral." But apparently this does not happen.

The English content can be restored by adding English as language (admin/config/regional/language) and rebuilding the cache (drush cr).

Proposed resolution

  • Set the content language to Neutral when removing a language.

Remaining tasks

t.b.d.

User interface changes

None

API changes

t.b.d.

Data model changes

None

Comments

Sutharsan created an issue. See original summary.

sutharsan’s picture

Issue tags: +D8MI
sutharsan’s picture

Issue summary: View changes
gábor hojtsy’s picture

We cannot really set it to neutral if it had translations or if the English one was a translation. Neutrals are not supposed to have or appear as translations.

gábor hojtsy’s picture

Issue tags: +language-content
plach’s picture

These kind of issues have always been tricky, honestly I'm not even sure there's a proper fix.

I'd be tempted to close this as the current behavior is by design in a sense.

(Closed #2595137: Switching site language makes previously created nodes unusable as a duplicate)

gábor hojtsy’s picture

Right, we can try being draconian and not let you delete languages that have something stored with them, but that would require a new API. Its not like anything else does that. Eg. a node with an entity reference to another does not stop you delete either.

attiks’s picture

Maybe we can just change the message saying that the content is still preserved but no longer accessible and that the content can be restored by re-enabling the language?

If we want to get fancy, we may provide an option to copy the English data to another language?

plach’s picture

Maybe we can just change the message saying that the content is still preserved but no longer accessible and that the content can be restored by re-enabling the language?

I guess this could be a good compromise, since the following

we may provide an option to copy the English data to another language

is the kind of feature that brings very little benefit compared to the effort required to implement it (and maintain it!)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

HSteeb’s picture

About step 5 "Remove the English language":

As a user, I would expect: if I delete a language, ...

  • it prompts,
  • then deletes all translations in that language.
  • If the translation is the single one for an entity, it deletes the entire entity.
weseze’s picture

I just discovered a related issue to this that in my opinion breaks my site entirely...
The underlying problem is the same, but the steps are slightly different and the expected result looks like the entire site is broken. While I was expecting everything to work fine...

Steps te reproduce:
1/ Install Drupal in any language
2/ Enable language and content translation modules
3/ Configure a content type and make it translatable
4/ Create content and translate it
5/ Switch the default language and delete the original language Drupal was installed with
At this point I would expect the content to be shown in the remaining language, since I created a valid translation for it.
But the content is shown in the deleted language and I can not recover my translation.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Jorgee’s picture

I had same problem as OP, but the worst part is that node is unrecoverable because no matter how many edits you do, content will not show up.

I had to remove nodes and custom blocks created in 'en' and recreate them.

And this happened only because I needed a language for the strings only.

I don't understand why Drupal does not separate language and content language.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

heiligerbiber’s picture

This gave me a headache as I (as a fairly new drupal user) did the same as the OP. My page is is German-only but was installed with English as default language. At some points this was visible to the user (e.g. it says "None" in a form as default when nothing is selected) so I wanted to change the system language to German. To my big surprise, after activating German and removing English all content was gone. Well after finding this issue I could recover by re-installing English but still this seems like a major bug to me. Ideas:
- There should be at least a big warning.
- I didn't see that there is a language assigned to every node (at least in my monolingual setup there is no option to change the content language of a node). It would be great to have the option "Change language of all existing nodes to this language"
- When trying to edit a node where it seemed all content was gone it would be great to have some hint instead "No content in your default language available. But this node contains content in language 'en' which you don't have installed. Find some instructions on what to do now somewhere..."

avpaderno’s picture

mastap’s picture

Is there a viable solution to removing the default language?

We are in a situation when the site was made in English as main language, and Chinese as second language.
Now we need to remove the English from there.

We switched to Chines as default and removed English language

But we encounter many issues.
The node content disappear in Chinese. Especially in Paragraph

What is THE procedure to remove an original default language?
Thanks!

weseze’s picture

@MastaP: Not an official procedure, but we are using https://www.drupal.org/project/disable_language to just disable "English" in these cases.

mastap’s picture

Thanks. But we're not looking for a front end solution. We want to completely get rid of English on this site and put another language as "Original Language".

Seems this MIGHT in the right direction
https://www.theodorosploumis.com/en/blog/change-default-language-drupal-...

But in the end really, We wish there was a cleaner way to handle this situation where we want to REMOVE initial language

avpaderno’s picture

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8.9.x is now open only to security issues.

mastap’s picture

Right - This is cumbersome as 9 is not so widespread yet.
In any case this is ALSO a 8.x problem. Would be good to apply to multiple.

Is there a solution to this issue!?

Thanks

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

luke.stewart’s picture

Issue tags: +Bug Smash Initiative

Given the elapsed time. Just reconfirming that this seems stlll to be an issue. I have done the following (on 10.2.4)

Enabled: Content Translation, Language, Interface Translation. Configure related permissions.
Added the first language that showed up in select here: admin/config/regional/language
Enabled Content -> Content types Basic Page and Article to be translatable here: admin/config/regional/content-language

Added a new node of type Basic Page English with something in the body.
Added a translation for language 2

Set Language two to default here: /af/admin/config/regional/language
Deleted Language En here: /af/admin/config/regional/language

Refresh the node.
For the default language get the english version not language 2 as might be expected?
For the previous language 2 page get content not found.

I want to do more digging to replicate the steps in the original post. However It seems like comments 6 and 8 would perhaps agree that a good solution here is to better inform the user of what is actually occurring rather than add additional behaviour.

dianaprecup’s picture

I had the same issue on Drupal 10.3.10. I had the default language of a website in Danish, I installed the Norwegian one, selected as default language. When I deleted the Danish one, even if I had a confirmation popup which said that all the Danish content will be updated to the default language, this doesn't happens. The lang code become empty.
My solution to fix this issue was to run the following code in a hook_update_N:

 $database = \Drupal::database();
 $schema = $database->schema()->findTables('%');
 foreach ($schema as $table) {
  if ($database->schema()->fieldExists($table, 'langcode') && $table!='locale_file') {
    $resultsFound = $database->query("select * from ". $table." where langcode='da'")->fetchAll();
    if(count($resultsFound) > 0) {
      $database->query("update ". $table." set langcode='nb' where langcode='da'")->execute();
    }
  }
 }
and than delete the original default language (Danish).
So basically, I am getting all the DB tables, check if there is a langcode field, get all the records form that table and update the value to the new language

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.