views:

471

answers:

1

I would like to be able to query the current variation from within a web part or a control template so as to determine which language to use. If there is no variation then I will pick up the language from the request.

Is this possible?

Thanks

Paul

+1  A: 

Yep - you can find the information in the Variations class.

// found here: http://weblogs.asp.net/davidmccollough/archive/2009/05/12/multilingual-sharepoint-publishing-sites.aspx
string currentUrl = SPContext.Current.Web.Url;
ReadOnlyCollection<VariationLabel> variationLabels = Variations.Current.UserAccessibleLabels;

foreach (VariationLabel vl in variationLabels)
{
   if (currentUrl.StartsWith(vl.TopWebUrl, StringComparison.CurrentCultureIgnoreCase))
   {
      variationUrl = "/" + vl.Title;

      break;
   }
}
Henrik
Thanks! I'll try it out asap...
paul