Posts Tagged ‘Web Part Localization’
Getting the current users language programmatically
Running with multilingual sites in SharePoint 2010, it can often be relevant to programmatically figure out what language the current user has selected. In this case I am running an english site, where I have changed the language for my user to german.
There are several SharePoint objects one can consider to look in, for example SPWeb or SPUser to get the users selected language. In the picture below I have added a screenshot of a debugging session with the various relevant values I found.
In order to get the language selected by the user, you will have to access the property System.Globalization.CultureInfo.CurrentUICulture. Properties like SPContect.Current.Web.UICulture is not affected by the user selected language.
Multilingual sites in SharePoint 2010
It was with great anticipation I started looking into the support for multilingual sites in SharePoint. At a first glance it looks like all texts you expect to change when selecting a new language change. Menus, library titles, list titles and so on are instantly updated when selecting a different language. Even if you give a library such as “Shared documents” a new title, it is just changed for the current langauge (can be configured to override all languages).
Here I am running with english on a site collection created with german as the primary language. As the picture shows, all lists and library titles are in english as expected – not in german.

With this great start I was hoping to see the same for web parts, that web part titles change as we select a different language. Unfortunately thats not the case. In the picture below I am running english on a german site. And as the picture shows, all web part titles are shown in german and not in english which is the current language for my user.
So why is Microsoft considering web part titles as user defined content? Hard to say. What this do mean, is that we have to look into other ways of making web part titles work for multilingual sites. We can probably program our own web parts to support multilingual sites by overriding the Title property, but for any other web parts it looks like we are stuck with the sites language.



