Base on the comments above, you'll require to create an event handler which will reset the cache of the dictionary. The event handler will be executed on the events publish:end
and publish:end:remote
.
If I am not mistaken, the items are available on the target database (web) after publish but it reads the dictionary from a file (.dat
). So, it is the file that is still not yet updated.
I haven't yet jump into a deep dive on how the dictionary cache clear works but out of my mind, I think it is periodically updating the file, say every minute or 2.
Code Snippet
using System;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
public class ResetDictionaryCache
{
public void DictionaryClearCache(object sender, EventArgs args)
{
Translate.ResetCache();
Log.Info("Dictionary Cache has been reset", this);
}
}
Once that you have implemented the ResetDictionaryCache
event handler, you will need to create a config patch for the publish:end
and publish:end:remote
.
Config Patch
<event name="publish:end">
<handler type="Your.Namespace.ResetDictionaryCache, YourAssemblyName" method="DictionaryClearCache" />
</event>
<event name="publish:end:remote">
<handler type="Your.Namespace.ResetDictionaryCache, YourAssemblyName" method="DictionaryClearCache" />
</event>
You can also use the overload method ResetCache(bool removeFileCache)
. Just pass it true
and it will delete the file and then it will get rebuilt.
You'll still need the above if you are experiencing the below issues:
- Dictionary items showing Key value instead of Phrase text
- Dictionary cache not getting updated in remote instances such as CD servers
- Dictionary entry shows incorrect value by Translate.Text(“Keyword”) with Fallback language item turned on
Reference: Troubleshooting Issues with Sitecore Dictionary in Multi Lingual Solutions