Update: Release 126.96.36.199 uploaded 04 May 2009 with important fix - see Release 188.8.131.52 page for release notes
The SharePoint Language Store is a framework intended to make building multi-lingual SP sites easier. It does not replace variations, but is designed to hold translatable strings which are "page furniture", rather than authored page content.
Examples of such items could be:
- Search button text (e.g. "Go!", "Allez!" etc.)
- First item in a dropdown text (e.g. "Please select...", "Choisissez...")
In a multi-lingual WCM site, there are typically many such items. To illustrate, here's an example from the BBC site where I've highlighted all the strings which may need to be translated but which don't belong to a particular page:
This project is an adaptation of my
SharePoint Config Store
project, and follows the same principles:
- values are stored in a SharePoint list
- an API is provided to retrieve values with a single method call
- extensive caching is used for optimum performance
- easily deployed as a .wsp
The list has a column for each translation:
To add a new language to the store, simply create a new column following the naming convention.
To retrieve a value, we simply call the GetValue() method and pass the category and title of the item to retrieve:
string sSearchButtonText = LanguageStore.GetValue("Search", "SearchGoButtonText");
Alternatively, an expression builder is automatically configured allowing you to drop values into markup:
<asp:Button runat="server" id="btnSearch" Text="<%$ SPLang:Search|SearchGoButtonText %>" />
How the Language Store determines which language to retrieve
In the current implementation, the regional settings of the SPWeb are used to determine which translations are retrieved:
It's a single method in the code (a single line in fact!), so this scheme could easily be changed if you have a different requirement.
Note that when a value is requested, a fallback process is used for which column to get the value from:
- preferred culture (determined by SPWeb's regional settings) - e.g. fr-CH for French (Switzerland)
- preferred culture's parent - e.g. fr for French
- default language (determined by configuration) e.g. en for English
This is useful where some items might have a different version for say American English (EN-US) and British English (EN-GB), but other items don't require distinction so a single value can be entered into the parent column (EN). Columns in the Language
Store list just need to be named with the expected format to be recognised - this is (for example) "LANG_fr-CH".
Other bits and pieces
- All items are wrapped up in a Solution/Feature so there is no need to manually create site columns/content types/the Language Store list etc. There is also an install script for you to easily install the Solution.
- Caching implementation is currently based around a CacheDependency on a file - this enables the cache on all servers in your farm to be invalidated when an item is updated, but does require that all WFEs can write to this location (e.g. firewalls are not
in the way).
- The Language Store can also be used where no SPContext is present e.g. a list event receiver. In this scenario, it will look for values in your SharePoint web application's web.config file to establish the URL for the site containing the Language Store
(N.B. these web.config keys get automatically added when the Language Store is installed to your site). This also means it can be used outside your SharePoint application, e.g. a console app.
- The Language Store can be moved from it's default location of the root web for your site (to do this, create a new list (in whatever child web you want) from the 'Language Store list' template (added during the install), and modify the 'LanguageStoreWebName'/'LanguageStoreListName'
keys which were added to your web.config to point to the new location. As an alternative if you already added 100 items which you don't want to recreate, you could use my other tool, the
SharePoint Content Deployment Wizard to move the list.)
- All source code and Solution/Feature files are included, so if you want to change anything, you can.
- Installation instructions are in the readme.txt in the download.
A few more details/background in my blog post at