Gotcha: Dictionary entries, keys, diff tool and the “Furniture version”

This one got me pretty good…

We’ve been heavy at work with a rather large Sitecore solution when, from nowhere, the Diff tool started showing weird version numbers in the select lists. And by weird, I don’t mean like “Version 1.39202”, but replacing the version number with a string like “Furniture” altogether.

After quite a lot of investigation I concluded that the problem must be related to the Sitecore dictionary. We had defined a lot of dictionary entries for different words, using numbers as keys (we are using the numbers in order to map data in a key-value manner.)

What I couldn’t figure out was how the heck these strings show up in the Diff dialog.

After hunting down the (yes, lowercase s in shell, thank you very much) with my favorite tool of the moment (yes, dotPeek) I found out that the problem lies in Sitecore.Web.UI.HtmlControls.ListItem. The ListItem class actually calls Translate.Text() with the version number as translation key.

Why is this a problem?

Well, it wouldn’t be unless we actually use the version number (yes, the number 1, one) as key field in our name-value mapping. The reason we are using the key field isn’t really important but Sitecore decided to use this key and fetch the phrase field as expected by the Translate.Text method. And since Sitecore doesn’t care what database the dictionary item is stored in, we ended up with a translation conflict.

It is worth nothing that the ListItem class actually has support for ignoring translation (setting the IsTranslable property. And yes, it IS spelled Translable in the class).


After some thought, I yanked out the whole DiffForm class using dotPeek and added it to my project. I then added listItem.IsTranslable = false to the code (it’s in the OnPreRender method), changed the CodeBeside attribute of \sitecore\shell\Applications\Dialogs\Diff\Diff.xml to my own implementation and PRESTO no more Furniture versions!

Can’t really blame Sitecore for this, since it is, kind of expected behavior when calling Translate.Text, I just DO NOT understand why translation is needed at all for the Versions list.

I’d be happy to provide any one with the code if you need it! Just drop me an email or a comment.

Posted in Sitecore Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *