Creating multilingual Site Definitions with Visual Studio 2010 SharePoint Development Tools

, , , ,

When working on SharePoint Solutions one of the common requirements is delivering multilingual solutions. Depending on your scenario you might either need to localize a single Web Part or a complete Solution. Thinking of multiple languages you have to take into account not only the development but also the packaging process for all the different assets in your Solution. One of such assets, where implementing support for multiple languages in SharePoint 2010 might seem complex at first sight, are Site Definitions. However you can easily create a multilingual Site Definition using nothing more than the standard capabilities  of the new Visual Studio 2010 SharePoint Developer Tools.

If you look at the new Visual Studio 2010 SharePoint Developer Tools, it seems like they have no support for localizing custom Site Definitions at first. If you create a custom Site Definition using the standard toolset, you get a Site Definition that is bound to a specific language by the Deployment Location of the WebTemp*.xml file.

Custom Site Definition created using the Visual Studio 2010 SharePoint Developer Tools

As you might know, localized Site Definitions share all the resources except for the WebTemp*.xml file. The WebTemp*.xml file contains the localized names of the specific Configurations and points to the shared onet.xml file. While the name of the WebTemp*.xml file doesn’t matter that much (as long as it matches the WebTemp*.xml pattern) it is a good practice to append the the identifier of your custom Site Collection to the WebTemp prefix to make it easier to track all Site Definitions installed in the Farm.

If you look at the custom Site Definition that gets created by the Visual Studio 2010 SharePoint Developer Tools you might see one challenge with delivering a multilingual Site Definition. As you can see all files (default.aspx, onet.xml and WebTemp*.xml) are in the same directory. In order to deliver the translated version of your Site Definition in another language you would have to create a copy of the WebTemp*.xml file, but you cannot have two files with the same name in the same directory, can you? So what are the options?

A few approaches that are not quite what you really want…

First of all you could create a new Site Definition project for every translation of your Site Definition. By sharing the common files like pages and onet.xml you could get the job done, but it would make the packaging process unnecessarily complex. First of all you would have a few projects with only a couple of files, and additionally you would end up hacking the identifiers to get it all right.

Another thing that you might try is to choose a different name for every WebTemp*.xml file, for example one that includes the locale like: WebTempMySiteDef1033.xml. This would definitely work and it would allow you to get it all done within a single project. It would be quite quirky though with all the different names and definitely not intuitive for someone not involved with the project during the development stage as it doesn’t follow the good practices. But there is however one more approach worth trying…

Creating multilingual Site Definitions the proper way

One more thing that you could do is to create a directory named after the locale for every language that your Site Definition should support. That would allow you to use the same names for the WebTemp*.xml files and would prevent you from using hacks and dodgy workarounds.

The first step in this approach is to create a regular Site Definition using the Site Definition SharePoint Project Template.

Creating a custom Site Definition using the Site Definition SharePoint Project Template

Then you would create a directory named after locale for every locale that your Site Definition must support:

Custom directories created for every locale supported by the Site Definition

The next step is to move the original WebTemp*.xml file to one of the locale directories and copy it to all the other locale directories translating the contents to match the locale:

Site Definition with folders for every locale supported. Each locale folder contains a WebTemp*.xml file named after the Site Definition.

The final piece of the puzzle is to change the Deployment Location of each of the WebTemp*.xml files so that they are deployed to the location specified by the locale folder. You can do that using the Properties Window of every WebTemp*.xml file:

Changing the Deployment Location for a WebTemp*.xml file using the Properties Window

And that’s it. Using this simple solution you can develop and package a multilingual Site Definition using the standard capabilities of the Visual Studio 2010 SharePoint Developer Tools and not a single hack!


Possibly related posts

16 Responses to “Creating multilingual Site Definitions with Visual Studio 2010 SharePoint Development Tools”

  1. Tweets die vermelden Creating multilingual Site Definitions with Visual Studio 2010 SharePoint Development Tools - Waldek Mastykarz -- Topsy.com Says:

    [...] Dit blogartikel was vermeld op Twitter door Waldek Mastykarz, Planet SharePoint. Planet SharePoint heeft gezegd: Waldek Mastykarz: Creating multilingual Site Definitions with Visual Studio 2010 #SharePoint Development http://planetsharepoint.org/1bd8c6 [...]

  2. Jonas Says:

    Good post!

    How about the onet.xml? Wouldn't I need to place that in the LCID sub folders as well? For example, I specify language specific titles for pages in the onet.

  3. Waldek Mastykarz Says:

    @Jonas: while you could of course do that, I think that it would be a better idea to use Resource files for that, so that you have one globalized copy of onet.xml and a Resource file for every language that your Site Definition supports.

  4. Dhawal Seth Says:

    Hi Waldek,
    A knowledge filled post indeed. I have a problem, I want to create multilingual sites but seem to hit a roadblock when trying to achieve this using sharepoint 2010's VARIATIONS and Content DEPLOYMENT features. Can you provide me an approach?
    My requirement is that, the content should be editable from the target sites as well and all the metadata should be in the respective language as well.

  5. Waldek Mastykarz Says:

    @Dhawal: First of all when using Content Deployment you cannot edit content on the target site. That's just how things work in SharePoint. As for the metadata: what is your challenge exactly?

  6. Jasper Says:

    Hey Waldek,

    I've got a case in which the customer wants sites in two different languages. I create the sites programmatically based upon a custom site defintion. Suppose I want a different default page for Dutch and one for German; what would be a good approach to acheive this? And how do you go about for webparts? Is that all managed in resources files?

  7. Waldek Mastykarz Says:

    @Jasper: if you have two separate sites for which you want different default pages, what you could do is to configure the Welcome Page of each site to your desirable page. Although I haven't tested that I would assume that the default variation redirect doesn't redirect to a specific page but rather to a site which should pick up your alternative page. As for Web Parts it depends on your implementation: you can use Resource files but if you want the content editors to be able to manage the labels a solution such as the Language Store might be a better choice.

  8. Usman Says:

    Good post!
    I have similar requirement where client wants site in 2 languages.
    I can either create seperate sites for English and French, with different contents
    Or same site, but some how, update the site/Pages content to display English or French when language is changed?
    What could be the solutions for this???
    Also if i go with the two-sites solution, is their a good practice of the "URL" naming convention?
    e.g.
    http://www.domain.com/sites/en/
    http://www.domain.com/sites/fr/
    or
    http://www.domain.com/sites/_EN
    http://www.domain.com/sites/_FR
    etc?

  9. Waldek Mastykarz Says:

    @Usman: Have you considered using Variations?

  10. Krishna Says:

    Hi Waldek,
    I have a requirement like, I want to create a custom web template from basis team site with additional custom lists, document libraries of SharePoint 2010. This web template is supposed to used by users in different lanuages like English, Japanes, French, German, Spanish. Is there anyway I can create a web template that supports all the above languages and when user selects a language in "Create Site" page, the created site will be in that particular language with all list/document library titles also shown in the respective language.
    Note: I want to achieve this by using the Web Templates as they can be stored in the Solution gallery and can be made changes as and when required. If I go with Site Definations, the hosting environment may not allow me to copy the site defination files to web front end server.

    Thanks

  11. Waldek Mastykarz Says:

    @Krishna: Have you tried using the Locale attribute in the WebTemplate element as shown in the SDK (http://msdn.microsoft.com/en-us/library/ff408392.aspx)?

  12. Leo Says:

    thank you very much for the post. It really saved a lot of time. I really appreciate.

  13. Raghavendra Shanbhag Says:

    Hi Waldek,

    Thanks for sharing the post. I wanted to know what would be the better approach for creating multilingual site(in
    Ex: Chinese, Portuguese, Japaneses etc) with a given generic site template developed in English. Each of these multilingual site which will have different content. At first Is this possible? I am not sure if content deployment of source and destination would help in such scenario.

  14. Waldek Mastykarz Says:

    @Raghavendra: Have you considered using Variations?

  15. MultiLingual Site Definitions « Sladescross's Blog Says:

    [...] http://blog.mastykarz.nl/creating-multilingual-site-definitions-visual-studio-2010-sharepoint-develo... [...]

  16. Create a Custom Site Definition with Additional Content in SharePoint 2010 Using Visual Studio 2010 | Sharepoint Sriram Says:

    [...] Creating multilingual Site Definitions with Visual Studio 2010 SharePoint Development tools http://blog.mastykarz.nl/creating-multilingual-site-definitions-visual-studio-2010-sharepoint-develo... Share this:TwitterFacebookLike this:LikeBe the first to like this [...]

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2012 Waldek Mastykarz

Creative Commons License