Friday, 8 May 2009

Finding the language packs installed on a SharePoint Server

I spent a hour or sow looking for a way to find all the installed languages on a server so I could update one of the XML files via a feature (I will post later about Installing a Theme across multiple front end servers targeting multiple languages).

The file I want to modify was SPTHEMES that is located at TEMPLATE\LAYOUTS\{LCID}\SPTHEMES.XML, There is a unique file for each language.
I thought that there must be a class in the OM that would allow me to get the installed languages. After diving in to the SPFarm object, digging in the NewSitePage class and a number of web searches while still getting no where I stumbled on the most simple class. (YaY for Reflector)

SPRegionalSettings and its GlobalInstalledLanguages property.

SPRegionalSettings.GlobalInstalledLanguages is a collection of SPLanguage objects.
each SPLanguage object is a simple data object that contains DisplayName and a LCID propriety.

so with this simple for loop I managed to avoid messing around with searching through the File system.

foreach (SPLanguage language in SPRegionalSettings.GlobalInstalledLanguages)

Sometimes the simple solution takes the longest to find.
Hope this helps someone.

No comments: