Refresh Sitecore dictionary entries

In this post, I will talk about an issue I experienced when using Sitecore Dictionary items which are very useful when you want to display a text in different languages, depending on the current language, and make this text content managed.


By default, the Dictionary items are defined in /sitecore/system/Dictionary and you can change it by creating a new “Dictionary Domain” item (using the template: “/sitecore/content/Seminole/Wildcard/Global/Website Dictionary Domain”),  anywhere we want (i.e. “/sitecore/content/home/Website Dictionary Domain”). Besides adding this new item, we need to specify the dictionary domain ID in your site’s definition, adding a new attribute “dictionaryDomain”:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>
	<site name="website" ... dictionaryDomain="{E95A2ED3-2A26-43F5-BD46-A65DBA713877}" />            
    </sites>
  </sitecore>
</configuration>

In order to use a dictionary entry, we should add a new item under the dictionary we just created, using the template: “/sitecore/templates/System/Dictionary/Dictionary entry”. This template has two fields:

  • Key: the Key field in this template defines the value to translate
  • Phrase: the Phrase field contains the translated value

We can group entries into folders using a Dictionary folder template.

We need to use the code below to get the dictionary phrase specifying the item key:

Sitecore.Globalization.Translate.Text("key")

I experienced an issue with dictionary items displaying always the Key value instead of the phrase and tried some of this actions:

  • App pool recycle
  • Rebuild the solution
  • Republish and reindex items
  • Clearing Sitecore cache
  • Removing the dictionary.dat located at Website/temp/

I found two alternatives to resolve this issue in case the other options didn’t work

1. Execute the following code (you can create a custom command and add a button to the ribbon)

Sitecore.Globalization.Translate.ResetCache(true);
Sitecore.Diagnostics.Log.Info("Dictionary cache was cleared", this);

2. Execute the following script using PowerShell Extensions Module.

[Sitecore.Globalization.Translate]::ResetCache($true)
Write-Host "Done!"

Now, the dictionary entries should be already fixed; that means the phrase should be displayed instead of the key.

Happy Sitecoring 😉

One thought on “Refresh Sitecore dictionary entries

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s