I was pretty sure, the use of dictionary items for translation was pretty quick, due to the fact that Sitecore caches the dictionary into a binary file but...
It turns out that when you use the domain, the first thing that Sitecore (always) does is look for the domain item with this query:
fast://*[@@templateid='{0A2847E6-9885-450B-B61E-F9E6528480EF}' and @@key!='__standard values']
This can explain why you see the direct SQL queries. It does a query across the whole content looking for items with template "Dictionary Domain"
You can avoid this query by passing the item ID (as string) of the domain, instead of the domain name, as if the text is an ID (ID.IsID(str)
) Sitecore does a GetItem. Please note I never tried this approach, it is only based on the piece of code I just read.
Once it has the domain, then it calls TryTranslateTextByLanguage, which is the one that actually uses the binary file (dictionary.dat).
Translate.TextByDomain()
and notTranslate.Text()
with domain specified per site in config asdictionaryDomain
attribute? Same issue would exist that Vincent highlights, but you can set the ID in the config. Worth mentioning since the code is cleaner and more re-usable.