Antti Alasvuo
Nov 25, 2020
(1 votes)

Export selected languages

Ever needed the functionality to just export the selected languages in Episerver instead of all languages which is the default behavior? If Yes, then this post is for you.


Little background for the post and small add-on I've added to Episerver NuGet feed. I'm working on a project where we are going to migrate thousands of pages from old site to a new site. There are just few buts.. our source site uses tens of languages where usually master language is English but there are some single pages here and there where the master language is not english. Our destination has just two languages enabled. So when we export content from source site even small selected sections for export can grow to huge export packages like the worst ones are 1GB! So if we could only define which languages to export we could cut down the size of the export package.

We've built an import pocessing 'framework' in the destination site that manipulates the content in import as we have different content types in the target site (solution). Also if there are unsupported languages in the content we discard those versions (master or language branch). Also the processing can transform content types from source to destination content types - so when we do import there are zero warnings :) Our import processing utilizes the EPiServer.Enterprise.IDataImportEvents and does the magic there. Have to say I'm happy how well it has worked but that was not the point of this blog post but the export languages, maybe more about the export / import migration in another post :D


Episerver exposes events during the export which we can hook to, see the EPiServer.Enterprise.IDataExportEvents. So I wanted to know if I hook up to the Starting event could I say to the export that it should only export the languages I supply to it. And yes it is possible to supply a list of languages for the export (see the code in my repo) so in the Starting event of export we get ITransferContext which inherits ContentLanguages property from IContentTransferContext which is a list of languages. If no languages are supplied then all languages are exported and the language value in the list is any valid culture name like 'en' or 'fi' (see CultureInfo.GetCultureInfo(string)).

After the POC we needed a way to be able to configure the languages - hard coding the values to the event was not an option because we still should be able to export all languages for example if we need to move small amount of data from production to test or development environment. So for that I utilized the old but still working GuiPlugIn and PlugInProperty attributes together with PlugInSettings to persist and load the configured settings.


Export languages configuration is done from Admin views 'Config' tab and using the Plug-in Manager.

  • click the 'Swapcode.EpiExport.LanguagesSelector'

  • next you will be shown a list of checkboxes of the languages enabled in your system
  • select the languages you want to include to the export and click save

Just remember to uncheck the checkboxes after your export and save that Episerver default export functionality is used again.

What it does not do?

It just sets the languages but this does actually mean language branches - so for example you have a page created in English (master language) and then you have translated that page to three other languages like Finnish, Swedish and Latvian. If you now set in settings that English and Finnish languages are used in export you will only get the en and fi languages to the export package.

Lets take the example one step further and add pages under the above sample pages but create each page in differen language (so master language is not en but some other language for each page), something like this:


Now if you export the 'Group masterlanguages' and have the export setting 'Include sub items' selected You most likely would expect the export to only contain the container and the 'en' and 'fi' pages but you will actually have all the pages in this case - this is Episerver export defaul behavior, it includes all master language versions as those have the not culture specific values.

The same will be true for blocks (or any other localizable content) - so cases like if you have blocks in the 'For This Page' assets folder all languages are exported even when you have specified that only certain languages should be exported.

So remember the above if using this add-on (at least for the initial version 1.0.0).

I did try to exclude content in the ContentExporting event using the selected languages but when I removed content in export the generated export package failed to import. There was an XML Element error during import (maybe I will write something in another blog post about the Episerver *.episerverdata export package ;-) ), I do know where the error is in the XML file in theory but import is reading the XML file in parts and the line number is not true when looking at the whole XML file and in my case that XML file was 25MB and I didn't have time to start splitting it and investigate it as in our import processing "framework" we are already handling not supported languages (not enabled languages) so it was not that big issue for us other than we couldn't make the package even smaller.

NuGet package and sources in GitHub

Sources are in GitHub:

NuGet package is in Episerver NuGet feed:

In our project we have already added additional filtering to the export and I will most likely add that soonish to this package (but then it is no longer just about languages, so the add-on naming no longer is correct :D).

I will also try to look in the issue about excluding content in the ContentExporting event and what causes the import to fail - it could be the data or a bug in the export.

Nov 25, 2020


Please login to comment.
Latest blogs
Caching & Rendering of metadata from the DAM

For the EPiServer.Cms.WelcomeIntegration.UI 1.2.0 release, we have facilitated the ability to cache and render metadata from assets within the DAM....

Matthew Slim | Jun 2, 2023

Conversion Rate Optimization: Maximizing ROI through Data-Driven Decisions

In today's digital landscape, businesses are constantly looking for ways to improve their online presence and drive more conversions. One effective...

JessWade | Jun 1, 2023

Enhance Your Writing with Suggestions

Are you tired of staring at a blank screen, struggling to find the right words? The Epicweb.Optimizely.AIAssistant Addon is here to revolutionize...

Luc Gosso (MVP) | May 31, 2023 | Syndicated blog

Content Graph - Letting GraphQL do all the hard work for you

Background As we have seen before, setting up Content Graph on the CMS side is pretty easy. However, when it comes to the “head” part of the setup,...

Kunal Shetye | May 26, 2023 | Syndicated blog