Sitecore Dictionaries are a powerful tool if used correctly… Unfortunately Sitecore Dictionaries are often misused from Sitecore newbie developers and I have seen dictionaries leading to catastrophic consequences for the project…
let’s go with order:
What are Sitecore Dictionaries
Sitecore allow the developer to define Dictionary when you need to define a simple association Key Name – value Name for your resources.
Typically the developers will hardCode the keyName of the dictionary within the code of the Rendering.
You could have global dictionaries and you could define global dictionaries that could variate for each site of your multisite implementation.
More reference on domain dictionary can be found here
Dictionaries support multiple languages and it reuse Sitecore logic for localization (such as language fall back etc)
further reference on the language fallback of Dictionaries can be found here
When shall you use Dictionaries:
The more common scenario where you should use Dicitonary is for static labels that you use for your website, eg. the text that you display for a button.
The main difference between using a Dictionary versus the Datasource item association is that Sitecore dictionaries have a simple structure and do not allow the content authors to change the datasource/behavior of your rendering but allow the content authors just editing the text of the label.
Typically you would use a dictionary for content that does not change very often and for simple content elements such labels of a button
When you should not use it:
Since Dictionaries are “Hardcoded” in the rendering, the use of Dictionaries for certain resources would mean that you cannot take advantage of the personalisation and testing functionalities for the resources stored in the dictionary
you have also to take in account the fact that you “loose” the flexibility for Content Authors to associate the Item Datasource in the name of a SIMPLER solution…
How could you use it:
There are several way to reference to a dictionary key:
Directly in your View
Directly in your Controller
Exposing the Dictionary values as a WebApi Endpoint (especially in the case that you can cache with your CDN) there are several examples that explain how to build your webApi endpoint..
Creating a static JSON file for each language when the content authors publish the Dictionary item
I hope this post helped you to clarify all what you need to know about Sitecore Dictionaries…