Try our conversational search powered by Generative AI!

Delete Language Branch from All pages and site

Vote:
 

Hi i want to delete a language branch from all pages where its used and from the website. On my site I have multiple language support over 1000 pages with I dont know exactly how many pages use polish (PL) language.I want to remove polish language. I just simply want to delet the language and all pages at once instead go page by page and delete polish individually and then from the site. I am unable to delete when i go to Admin>Config>Manage Website Languages I get this error

The language is used in language settings on the following pages and cannot be deleted: Root [1], Home [3]....

Deleting language from individual pages is not so option as there are so many pages in the website.

Can some one kindly help me out with this?

#89981
Aug 29, 2014 16:42
Vote:
 

Not sure that's possible, at least nowhere in the UI.

Seems like you'd have to write a small job to loop through your pages and delete that specific language branch.

There are "delete language" methods in both the EPiServer.DataFactory and EPiServer.DataAbstraction.ContentStore namespaces, but they all take a PageReference or ContentReference as parameter, meaning they will only delete the language for the specified page, not all pages in the content tree.

E.g. 

EPiServer.DataFactory.DeleteLanguageBranch: http://world.episerver.com/Documentation/Class-library/?documentId=cms/7/c8ac5c2b-ff67-869d-e6f3-8703e864f387

EPiServer.DataAbstraction.ContentStore.DeleteLanguage: http://world.episerver.com/Documentation/Class-library/?documentId=cms/7/0feec2ec-d9b3-39bb-4bb6-40f8f8a791d6

#89989
Aug 31, 2014 0:23
Vote:
 

Just for reference, I'm posting the updated solution by Adnan here:

http://www.adnanzameer.com/2014/09/delete-language-branch-from-all-pages.html

#119652
Edited, Apr 01, 2015 0:20
Vote:
 

The following code seems to work for me... Easy enough to wrap in an admin plugin.

var pages = _contentRepository.GetDescendents(ContentReference.RootPage);
var datafactory = new DataFactory();
foreach (var page in pages)
{
	try
	{
		datafactory.DeleteLanguageBranch(page, language, AccessLevel.Delete);
	}
	catch (SqlException)
	{
		// Ignore whether the page exists in the language or not
	}
}
#119656
Apr 01, 2015 2:10
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.