Deleting a Language in Sitecore - Be Careful

Posted 06/30/2016 by DeBruin

Hello. Recently we were tasked internally at NTT with becoming more active on the NTT blog and posting Sitecore related issues. So from here on out I'll be posting from time to time on issues that I think Sitecore devs and architects might be interested in. I've been architecting Sitecore solutions all the way back since Sitecore 5.3 which I think puts me at around 8 total years of Sitecore experience at this point in my career. I also used to work at Sitecore as as trainer and architect. Over the 8 years I've lost count of how many total sites I've worked on but it is a lot. I will be sharing things, hopefully that aren't covered too much elsewhere, that have come up over those 8 years and hopefully you can benefit from my posts and experience. With that introduction covered now on to the post itself. 

This post is more of an FYI than anything but it's important to understand and not understanding this could have dire consequences for a project. 

Let me pose a question to you. Let's say you want to delete a language from your Sitecore instance, in this case Polish. Is there anything special you have to be aware of? The answer is yes. There is a very big GOTCHA when dealing with deleting languages in Sitecore. Let's walk through this example. 

In this post I am using Sitecore 8.1 rev 160519. 

Currently in our example tree we have the Polish language which we would like to delete. Here is a closeup of the /sitecore/system/Languages section of our tree:

languages_closeup

And here is the Home Item in our tree with some Polish content:

home_item_polish_content

And if I click the language popup in the upper right of the Content Editor with the Home Item selected I see this:

language_versions_for_home_item

So far this is all standard and I'm sure you are all familiar with what you've seen so far. We have a Home Item, that Home has a language version in Polish with some Polish content and we verified that by looking at the language popup in the upper right of the Content Editor next to the version number for that piece of content. 

Now for whatever reason we have decided to delete the Polish language from the Content Tree. Maybe we had set up the site to use multiple different languages and now it was decided by the powers that be that one of the languages won't be part of the launch. We go back to /sitecore/system/Languages but this time we are going to delete the Polish language. 

We go ahead with deleting the Polish language from the tree by selecting the pl-PL Item and then clicking on delete:

delete_polish_confirmation

We then click OK on this dialog and we see a 2nd dialog appear:

delete_polish_content_warning

It says you are about to delete the Polish language and that it will remove all content in Polish. Great, that's exactly what we want. We go ahead and click OK. 

Now under /sitecore/system/Languages we see that Polish has been deleted:

And on the Home Item if we look in the language popup we see that Polish is also gone there:

And if we look in the Recycle Bin we can see the Polish Item that we deleted from the Content Tree just as we'd expect:

polish_item_in_recycle_bin


Now what if we decide we want to add the Polish language BACK to the Content Tree and the Polish content back into our site? We follow the same process we normally would by selecting the Item in the Recycle Bin and clicking Restore:

restore_polish_language_item

After restoring the pl-PL Item we check the /sitecore/system/Languages section and see the Polish language Item has been restored:

polish_restored

And now we go back to the Home Item to see if that content has been restored:

language_versions_after_polish_restore

It's gone! The Polish content for the Home Item wasn't restored when we restored the Polish language Item from the Recycle Bin. This is the gotcha I was talking about earlier and the point of this post. Remember this dialog when we were deleting the Polish language:

delete_polish_content_warning2

That dialog was telling you what you just learned. "This will remove ALL the content in "Polish." You see when you delete a language Item in Sitecore it performs a SQL delete on the backend of all of the content associated with that language. Because you see the language version Item in the Recycle Bin most people assume that restoring this Item will restore all the content associated with that language but it does not. And if you think about how Sitecore works it makes perfect sense. 

The Recycle Bin is used to hold Content Items that are deleted from the Content Tree. The language versioned content associated with a particular language isn't represented in Sitecore by Content Items. Language versioned content is essentially metadata associated with Content Items. So once you delete that language settings Item in the tree it deletes all of the language content associated with that settings Item. Restoring that Item will only restore the language Item itself and not the content associated with that language Item. 

The takeaway from this is that if you are going to delete a language in Sitecore make sure you are OK with losing all of the content associated with that language as well. Because once you click OK on that dialog above the language content associated with that language you are deleting is gone. 

Share:

Archive

Syndication