nLastnweek I was doing some R&D on SharePoint Multilingual user interface andnhence thought to share some learning experience which I got.
n
n
n
n
nBackground:
n
nSharePointn2010 ships with the new feature called Multilingual User Interface, which isnhelpful for displaying the content in the web site in various languagesndepending upon user selection. I will not dive in to the much details of it asnmany of good posts are available on the same. Some examples can be found Here and Here.
n
nJust anbasic rule of this feature is, it works on the UI culture of the currentnthread, and shows content to user in different languages.
n
n
n
nProblem:
n
nSo farnso good, SharePoint 2010 manages to translate all link titles, list, librariesntitles, site columns titles, content type’s titles and many more things whichnare out of the box. So when user selects a different language in MUI selectornmenu then he or she is able to see the OOB translated content very well , butnwhat happens when we have our custom lists, list web parts, custom sitencolumns, content types ? Those don’t get translated by default.
n
n
n
nSolution:
n
nOne hasnsaid very well, there is always a solution J and this line cheers me up. So to overcome thisnkind of scenario there are two ways.
n
n
n
n1. Manual Approach: one has to go toneach and every created custom lists, site columns, and content types and updatentitles of the same in different languages by changing languages every timenusing MUI selector. Though this sounds easy but takes lots of efforts when younhave sites already provisioned and there is lots of such custom data.
n
n
n
n2. Programmatic Approach: I alwaysnlove such approaches and so I always try to find way to do them as they makesnlife easy by just few clicks.
n
n
n
nAnproperty “TitleResource” is available now with somenSharePoint objects which is of type SPUserResourceclass, with which you can getnor set the titles of webs, lists, site columns, content types for multiplenlanguage cultures.
n
nFollowing example shows thatnhow we can get or set the multilingual values of a site’s title for German UInculture.
n
n
n
n
n
n
n
nusing (SPSite site = newSPSite(“http://YourSite”))
n
n{
n
nusing (SPWeb _web = site.OpenWeb())
n
n
nConsole.WriteLine(string.Format(“{0}-{1}”,n“Title”, _web.Title));
n
n
n
nSPUserResourcen_userResource = _web.TitleResource;
n
nifn(_userResource != null)
n
n {
n
n _web.AllowUnsafeUpdates = true;
n
n _userResource.SetValueForUICulture(newSystem.Globalization.CultureInfo(1035),n“German Title”);
n
n _userResource.Update();
n
n _web.AllowUnsafeUpdates = false;
n
n
n
nConsole.WriteLine(“{0}-{1}-{2}”, “UpdatednTitle for Culture”, “German”,n_userResource.GetValueForUICulture(newSystem.Globalization.CultureInfo(1035)));
n
n
n
n}
n
n }
n
n}
n
nConsole.ReadLine();
n
n
n
n
n
n
n