I’ve seen a couple of posts recently regarding custom implementation of the Sitecore Dictionary or some sort of custom functionality for handling multilingual content labels. My question is Why?
Ever since Sitecore Dictionary Domains were introduced in Sitecore 6.6 I’ve thrown away my custom Dictionary functionality in favour of the new out-of-the-box Dictionary Domains.
Dictionary Domains are great because:
- No more Dictionary under the System node – You can add a dictionary anywhere in the content tree. You are no longer tied to using the default dictionary located under the System node in the content tree. The default dictionary is not in an optimal location since most content authors will not have the proper security permissions to access it in that area. Instead you can now add one or more dictionaries under the Content node so you can easily add/deny access rights like any other content. This alone is enough for me to use Dictionary Domains!
- Separate dictionaries for multi-site solutions – You can add many different dictionaries to better separate multilingual labels. You can imagine that this is fantastic for multi-site solutions since it is incredibly easy to add/deny users access to certain dictionaries depending on what sites they have access to. Furthermore, you can set each dictionary to have a fall back dictionary so that it can reference a different dictionary if it can not find the proper key itself.
- Enhanced re-usability with separate dictionaries for modules – Having separate dictionaries is also great when creating reusable packages or modules. You can create dictionaries in a modular fashion that can be installed on their own so it’s easy to discern which dictionary items belong to which modules.
I find that a lot of people have had pretty poor experiences with the built in Sitecore dictionary in the past. And rightfully so! Personally I don’t think the Sitecore dictionary was ready for prime time until the Sitecore 6.6 release.
Sitecore 6.6 introduced the Dictionary Domains (that I spoke about above) and also fixed a NASTY bug in Sitecore 6.5 that rendered the Sitecore dictionary unusable in a multi-server environment. I can assure you that things are now in good shape and it’s probably time to give the Sitecore dictionary another chance if you’re not using it.
You’ve probably seen the following code snippet to call the default Sitecore dictionary.
And here is the snippet to call a specific dictionary domain. The first parameter is the name of the dictionary domain you are referencing.
Sitecore.Globalization.Translate.TextByDomain("Site1 Dictionary", "text-label-key");
Having said everything above, there are definitely still situations where it makes sense to create your own custom dictionary functionality. One of the more interesting implementations I’ve seen was from Tim Braga where he creates a model of the Sitecore dictionary so dictionary terms can be referenced as objects much like you would reference Sitecore items in an object mapping framework. Pretty cool!