Variations are very important when developing multi-language sites.
They allow the creation of sites in different languages, typically for publishable content. For example for an international site, in the Swiss site there could be the German site (the main sub-site) and the other variations: French, Italian and eventually English.
The steps to enable variations are:
- install the operative system language packs for all the desired languages (in the example above, it would be for German, French, Italian and English);
- install the WSS and SharePoint language packs;
- from the site settings of the root site, enable variations (in the example above, it would be in the Swiss site);
- from the site settings of the root site, create variation labels for the desired languages (in this case, it would be for German, the main language, and for the other languages French, Italian and English);
- from the same previous page, create variations: this will physically create the sub-sites.
Enabling variations for SharePoint 2007 is described in the article How to setup variations in MOSS 2007.
Another well done guide for variations in SharePoint 2010 is in the blog post SharePoint Variations – The complete Guide – Part 1 – The Basics.
And finally, for SharePoint 2013, there is the official article from Microsoft Variations overview in SharePoint Server 2013.
During a site restore, I had the following exception: "Value cannot be null. Parameter name: g", as displayed in the picture below:
I've found the analysis of the problem in the forum post SharePoint 2007 blog site error - Value cannot be null. Parameter name: g: pratically there is some lookup column not correctly binded.
In SharePoint there are already a lot of translated strings, that you can find in the resx files in the folder C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\Resources.
You can incorporate them in your resource files in the form $Resources:StringID;. For example you can use:
To access them from C# code, you can use the method SPUtility.GetLocalizedString.
For example, to retrieve the name of the Document content type, it is possible to use the following line:
string documentCTname = SPUtility.GetLocalizedString("$Resources:Document", "core", web.Language);
In SharePoint 2007, there was an useful tool to design and create new CAML queries: it was U2U CAML Query Builder.
Sadly it hasn't been updated for SharePoint 2010, and it seems that it is not available anymore.
The blog post U2U CAML Query Builder for SharePoint 2010? suggests two tricks:
- connect the old CAML query builder (for SharePoint 2007) to SharePoint 2010 via web services;
- design the new query with LINQ to SharePoint, then trace its output as described in my previous article Linq to SharePoint 2010: how trace the CAML query.
Alternatively, it would be possible to use the CAML.NET library, to build CAML queries in a type-safe way.
Finally: the StackOverflow question U2U Caml Query Builder no longer available? suggests to use the following tools:
The best option I've found for content migration in SharePoint is the "SharePoint Content Deployment Wizard".
This works in SharePoint 2007, 2010 and hopefully 2013 :-)
When defining SharePoint DateTime fields, it is possible to define them as UTC, adding the following parameters:
StorageTZ = "TRUE"
In this way, the date will be saved indipendant of the regional settings of the user. The net result will be that the display date will vary based on the regional settings of the user.
This behaviour is described in the article What does StorageTZ = "TRUE" mean.
And in the article SharePoint Web Services and UTC time fun and games it is described the field behaviour in more detail.
Sometimes, when working with corporate machines, it can happen that you have security issues that make your SharePoint development harder.
One of these problems is that even if you are machine administrator, or you have started Visual Studio as administrator, you still have problems with deploies, or you have DLL locked in the GAC and you are not able to update/delete them.
The solution to this problem is to remove the admin approval from the local policies:
- run the Local Security Policy MMC snap-in (from the start menu, run, type Local);
- go to Security Settings | Local Policies | Security Options
- disable "User Account Control: Run all administrators in Admin Approval"
- reboot the machine
I've seen this trick in the blog post Access Denied trying to uninstall assemblies from GAC.
When you deploy pages in WSP, you can follow the instructions in this link: SharePoint 2007: how deploy pages and web parts via feature.
But if the site a publishing site, after the deploy there will be an error saying that the page layout is invalid. So, there are two choices:
I'm working on a project and I have to deploy web part pages via feature.
In SharePoint 2010 it is possible to create the pages and export the site in a .wsp, but SharePoint 2007 the export was done in .stp files.
So the solution is:
- create the feature and the related module;
- in the web part page, export the web parts in the page in multiple .webpart files, as described in the blog article Exporting and Importing a Web Part through the SharePoint UI;
- include the .webparts file in the module, as described in the blog post Quick Tip: Provisioning Web Parts to a Page.
In the article How to point to a custom 404 error Web page in SharePoint it is described how to to handle custom http 404 (file not found) error messages, with support to multilanguage.
This is for file not found errors only.
If you need to handle any http error, you can read the page Using web.config - Returning custom http error messages on IIS 7.5.