Monday, November 26, 2007

Enabling the language switch in SharePoint

Today someone at work pointed out that there was a switch control in SharePoint that allows users to easily switch between the different languages a page is available in. I hadn't heard of this already, so if you haven't either, now you've got no more excuses to say you don't!

Now what exactly does it do? Quite easy... If variations are enabled and there's a version of a certain page available in a different language, a switch will show up to easily switch between the different versions of the page. If your page only exists in English for example, the switch control won't show up.

But most importantly... How do you enable it? Well, that's easy too. All you need to do is follow some simple steps:

- Go to the ...\12\TEMPLATE\CONTROLTEMPLATES folder and open the VariationsLabelMenu.ascx file.

- Look for the line that's commented out. Remove the comment tags to enable the control. Here's the line you should comment out:

<cms:VariationsLabelEcbMenu id ="varlabelmenu1" DataSourceID="LabelMenuDataSource" DisplayText="<%$Resources:cms,VariationLabelMenuTitle%>" IsCallbackMode="true" runat="server" />

- Now go to the Master Page you want to include the control in and make sure that it has the following tag at the top:

<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>

If this tag is on your Master Page and you've commented out the control, then the switch control should be showing right beside the links in the upper right corner of the Master Page. Now you can use this control and put it where ever you want to. If you want, you can also use it like this:

<PublishingVariations:VariationsLabelMenu id="labelmenu1" runat="server"/>

Easy as that!

4 comments:

Unknown said...

How can I create my own or customize VariationsLabelMenu.ascx to function like how it is on this multilingual site - http://denny.denish.com/elearnexpo.com/paris/paris_venue.htm. I mean my client don't like the drop down function of the VariationsLabelMenu. They want it simple - Like on the english pages there should be a link 'français' which will link to the corresponding french pages and similarly on the french pages there should be a link 'english' which will link to the corresponding english pages. Please help.

Thanks.
Denny

Tom said...

Hi Denny,

I have never done such a thing myself and I'm at home now with no access to any SharePoint environment at the moment... But well, the first thing I'd try if I were you, is to create your own webcontrol that does the trick. You can look at this site for a great guid on how to create a webcontrol and use it in a Master Page:

http://blogs.msdn.com/msdnts/archive/2006/12/08/use-your-asp-net-webcontrol-in-moss-2007-with-sharepoint-delegate-control.aspx

Next, you create a code behind file and in there you write code that gets the URL of the current page you are on, replace the language bit and then make a link to it.

I'm sure there are probably better ways for doing this, but I'm pretty sure this one will work...

Unknown said...

denny if u made it, please tell me how as i want to do it too

thanks

paul said...

Sounds interesting! Has anyone done it and can point me to the web page?