Tuesday, May 8, 2012

Copy SharePoint Lists between sites with different language templates

An easy way to copy a list with content between to sites is to create a list template, upload it in the other site to the list template gallery and create a new list with the uploaded template.

The problem starts when the site templates have different languages. For example you create a list template in a site with english site template and you upload it to a site with a german site template, you'll not see the template in the create page.

A way to change this ist to modify the.stp file, which is created when you make the list template. SO the first steps are:
  1. Create a list template. You can do this in the list settings. Just click "Save list as template" and give in the the filename and the template name.
  2. Download the created template to a local folder.

Extract the template file

Now we will modify the .stp file. An .stp file is nothing more than a microsoft cabinet file. Therefore rename the file from "mylist.stp" to "mylist.cab". You can now open the file and see all the compressed files inside.

The next step is to make a local folder e.g "C:\temp\mylist" where we'll copy all files within the cab file. So open  the cap file and drag all files inside to the mylist folder. As it's a cab file you can't copy the files, you have the drag them with the mouse.

Afterwards open the manifest.xml in the mylists folder and change the language code within the xml to the destination language code. (See Language Codes )

<Language>1031</Language>

Create a new template

In this step we create the stp again. Unfortunately it is not so easy as it seems to be. First of all we have to create a .ddf file. Create a new file in the mylist folder and rename it to "definition.ddf".

Open the .ddf file and paste the fallowing code inside:

; DIAMOND Directive File (.ddf)
.OPTION EXPLICIT
; Generate errors on variable typos
.Set CabinetNameTemplate=mylist.stp
.Set Cabinet=on
.Set Compress=on

;The files specified below are stored, compressed, in the cabinet file
30000000.000
manifest.xml

In the last section write down all the files which should be within the new .stp file. These should be all except the .ddf file.

You can also change the CabinetTemplateName. This is the name of the file, but this is not important for us.

Create cabinet

Open the DOS command promp and go to the mylists folder. Type the following command:

makecab /f definition.ddf



The result should end in a mylist.stp file within a subfolder. You can now go and upload the new .stp file to the list gallery of your destination site.

The list template should be finally visible in the list create dialog.

9 comments:

Vaqar Hyder said...

Thanks a million dear Baris...
That was really helpful.
Keep up the good work.
Regards
Vaqar Hyder

john magdy said...

Thanks Baris, that was helpful.
But I still have a problem here. I've two lists, one of them have a field with type "look up" to the title of the other list .. When I use this method with the two list(I created the PrimaryKey list first) the lists is created successfully but with no records in the lookup field.

Anonymous said...

Hi,
I followed everything u said and uploaded the newly created STP file in the template gallery. But i cant see this file listed in the 'create new list' section. Any help wud be much appreciated.

Thank you

Baris Bikmaz said...

Hi,
when you not see the file, it is mostly a language problem. Is it the right language code ? The site and the list must have the same language codes. What have you done so far ?


Anonymous said...

Dear Baris,

Thanks alot! It worked well after I eliminated the line containing
30000000.000

Axel Neuhaus
Winterthur

Ghofretta said...

Thank youuuuuuuuuu you are genious !

Gianni Zanetti said...

Merci, thanks Baris

Anonymous said...

also for me It worked well after I eliminated the line containing
30000000.000

Thanks!!!

Sergio

Andrey Paltusov said...

I solved this problem using visual studio to create .cab. Thank you for good idea with locale changing!