LibrarySites.Banner

Sitecore ASP.NET CMS 6.6 Features: Dictionary Domains

This blog post describes aspects of the dictionary domain concept introduced in version 6.6 of the Sitecore ASP.NET web Content Management System (CMS). The content of this post derives from the "MVC and 6.6 Killer Features" presentation at Sitecore Symposium.

For years Sitecore has provided a translation dictionary system using Sitecore items. Sitecore uses this dictionary system for translating phrases used in user interfaces and other aspects of the CMS into any number of languages. Dictionary entry definition items use the System/Dictionary/Dictionary entry data template. The Key field in this template defines the value to translate; the Phrase field contains the translated value. To translate a value, developers pass a key to the Sitecore.Globalization.Translate.Text() method, and Sitecore returns the value of the Phrase field in the corresponding dictionary definition item for the appropriate language. If no such item exists, the Text() method returns the key itself. To optimize performance, Sitecore maintains one or more caches of translated key/phrase values.

To improve usability, Sitecore organizes dictionary definition items under items based on the System/Dictionary/Dictionary folder, such as the /sitecore/system/Dictionary/A item that contains dictionary entries for which the key begins with the letter A and the /sitecore/system/Dictionary/Z item that contains dictionary entries for which the key begins with the letter A.

Over time, Sitecore customers began using the dictionary system for their managed sites. This could lead to some confusion because dictionary entries could exist in the Core database, the Master database, and any number of publishing target databases, and it was not always clear to the developer which would apply. This could also present problems if the CMS and the managed site needed to define different translations for a given key.

Sitecore 6.6 introduces the concept of dictionary domains. In any database, you can create any number of dictionary domains, which are items based on the System/Dictionary/Dictionary Domain data template. Each dictionary domain can specify a fallback domain to use if the dictionary domain does not contain a definition item for a key. You nest dictionary domains; a dictionary domain can contain other dictionary domains. You can also define the dictionaryDomain attribute in each /configuration/sitecore/sites/site element in the Web.config file to specify the name or ID of the dictionary domain definition item to use for each of the managed sites.

In Sitecore CMS 6.6, the Sitecore.Globalization.Translate.Text() method invokes the getTranslation pipeline. The default implementation uses the dictionary domain in the content database (if the current HTTP request triggers one and the dictionary domain in that database contains a translation for the key), otherwise the context database (if the current HTTP request triggers one and the dictionary domain in that database contains a translation for the key), or the Core database otherwise. As with any other pipeline, you can add processors to, remove processors from, and override processors in the getTranslation pipeline. For example, when porting an existing ASP.NET site into Sitecore, you could add a processor that looks for entries in the resource files from the old site if no entry for a key exists in the Sitecore dictionary system.

Resources