2

The Export Languages feature is working but we would like to include Shared fields, but it doesn't seem as those are included. Is this possible out-of-the-box or is there some type of workaround that we would need to do in order to get those Shared fields included with the export?

1 Answer 1

5

The Shared fields are understandably not included as they don't need to be translated, as by their nature they are shared across all languages. As the Export Languages feature is to serve translation, it doesn't include them.

There is no out-of-the-box method to enable Shared field exporting in this feature.

Alternatives

Before looking at a solution. My initial question is to why you would want this feature? If your primary case is just to export the content from Sitecore and you don't need the exact schema offered by Export Languages, then I would look at alternative options such as:

  • Using serialization to output the items as .item files. OOTB behaviour
  • Using the Sitecore GoodOldWebservice (/sitecore/shell/WebService/service.asmx) which has a Get XML method. OOTB behaviour though you'll want an app to connect to the service, such as SoapUI. Note that the XML format is different to that in Export Languages.
  • Looking at modules such as the Export Item Data module. Not OOTB behaviour but should require no code.

Editing the Export Languages behaviour

The functionality that performs this export and the resulting XML schema is particular to this feature and can't be easily extended.

If you do indeed want to export all the data in the exact same format as this, your best bet is to decompile the Sitecore.Shell.Applications.Globalization.ExportLanguage.ExportLanguageForm in the Sitecore.Client assembly, create a new class from it and alter the behaviour. The part that you would need to change is in the ExportItem method:

protected void ExportItem(Job job, XmlTextWriter writer, Item item)
{
    //... code omitted ...

    foreach (Language language in this._languages)
    {
        foreach (Field field in item.Database.GetItem(item.ID, language).Fields)
        {
            // This should be replaced with a custom implementation of 
            // ShouldBeTranslated that doesn't check the Shared property
            if (field.ShouldBeTranslated)
            {
                ...
            }
        }
    }
}

You can then edit \sitecore\shell\Applications\Globalization\ExportLanguage\ExportLanguage.xml to use your replacement form instead by updating the following line to your new class:

 <WizardForm CodeBeside="Sitecore.Shell.Applications.Globalization.ExportLanguage.ExportLanguageForm,Sitecore.Client" Submittable="false">

Alternatively you can also just extract the code and run it manually if you don't have a need to replace the regular form's behaviour.

1
  • Great answer and exactly what I was looking for Kasaku. Thanks for the knowledge, thorough answer, and alternatives. Nov 1, 2016 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.