SPWeb.ExportUserResources method

Exports user resources for a given language.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public void ExportUserResources(
	CultureInfo language,
	bool allResources,
	Stream outputFile


Type: System.Globalization.CultureInfo

Specifies the language of the resources to be exported. The language must be listed in the collection returned by the SupportedUICultures property.

Type: System.Boolean

true to include all user-specified text, including text that has been translated; false to include only untranslated text.

Type: System.IO.Stream

The destination for exported user resources.


No alternate languages are enabled on the site.


The specified language is not one of the installed languages.


The language is not supported by the website.

The user resources are written to the specified stream in .Resx file format. For more information, see Resources in .Resx File Format. Text that has not been translated to the language specified by the language parameter is in the default language for the website. The default language for a site is returned by the UICulture property.

Caution noteCaution

Code behind the Export Translations page in the user interface calls the ExportUserResources method. However, the logic implied by the allResources parameter is exactly the opposite of the logic implied by the user interface, which offers the option to Only export text that is not translated. If you choose Yes, then page code passes false in the allResources parameter. If you choose No, then page code passes true in the allResources parameter.

The user resources that this method exports include not only resources for the website but also resources for lists in the site. You can call the ExportUserResources method to create a resource file for each of the languages supported by the site, and then give the files to someone who can translate the strings that they contain. When this work is complete, you can call the ImportUserResources method to import the translations, making them available to the multilingual user interface.

The following example is a console application that enumerates the languages supported by a website and exports untranslated resources for each language.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Microsoft.SharePoint;

namespace ConsoleApp
    class Program
        static void Main(string[] args)
            using (SPSite site = new SPSite("http://localhost"))
                using (SPWeb web = site.RootWeb)
                    // Get the default language for the website.
                    int lcid = (int)web.Language;
                    CultureInfo defaultCulture = new CultureInfo(lcid);

                    // Export resources for all alternate languages supported by the website.
                    if (web.IsMultilingual)
                        string resxFileName;

                        IEnumerable<CultureInfo> cultures = web.SupportedUICultures;
                        foreach (CultureInfo culture in cultures)
                            if (culture.LCID == defaultCulture.LCID)
                            // Export only untranslated resources.
                            resxFileName = WriteResourceFile(web, culture.LCID, true);
                            Console.WriteLine("Resources for {0} exported to {1}.", culture.Name, resxFileName);
            Console.Write("\nPress ENTER to continue....");

        static string WriteResourceFile(SPWeb web, int lcid, bool onlyUntranslated)
            CultureInfo ci = new CultureInfo(lcid);

            string fileName = web.Title + "." + ci.Name + ".resx";
            char[] invalidChars = Path.GetInvalidFileNameChars();
            foreach (char c in invalidChars)
                fileName.Replace(c, '_');

            FileStream fs = File.Create(fileName);
            web.ExportUserResources(ci, !onlyUntranslated, fs);
            return fileName;