Remove Language version of Sitecore Items

Many times you will come across scenarios where you need to remove specific language version of Sitecore items. Mostly in the multilingual websites, we do come across this kind of scenarios often.We can achieve this in multiple ways. Let’s look on How to Remove Language version of Sitecore Items in details.

Remove Specific Language Version of Sitecore Items Programmatically

The below code will remove the language versions of the root item path you specify and all the descendant Sitecore items.

public void RemoveLanguageVersion(string rootItemPath, string languageCode)
            Language languageRemove = Sitecore.Globalization.Language.Parse(languageCode);
            Item rootItem = Sitecore.Context.Database.GetItem(rootItemPath, languageCode);

            if (rootItem != null)
                using (new Sitecore.SecurityModel.SecurityDisabler())
                    //Remove language version from root item               

                    //Remove language version recursively from child items of root item
                    foreach (Item child in rootItem.Axes.GetDescendants().Where(x => x.Language == languageCode))
string rootItemPath = "/sitecore/content/Home";
string languageCode= "en-GB";

RemoveLanguageVersion(rootItemPath, languageCode);

The above code will remove all the en-GB language version in the home item and its descendant items recursively.

Remove a Language Version of Sitecore Item using PowerShell Script

Another best approach is to use PowerShell script to remove a specific language version. This is fast and easiest way to perform the task. The below PowerShell script will remove the en-US language version from home item and its descendants.

Step 1 : Open the PowerShell ISE console in Sitecore

Step 2: Modify the Path and language in the script for which you need to remove the language version.

Step 3: Execute the script in PowerShell ISE

$path = "master:/sitecore/content/home"
@(Get-Item $path) + (Get-ChildItem $path -Recurse) | Remove-ItemLanguage -Language "en-US"


Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like
XOR in Python

XOR in Python

XOR Operator in Python is also known as “exclusive or”  that compares two binary numbers bitwise if two bits are…
How To

How to configure Git proxy?

If you are working in the corporate company all the internet requests usually goes through the corporate firewall.…