Hi guys,
In almost every project we have a helper class which we use to retrieve a translation from the translation.xml when we are in code in stead of a template.
This has never given us any problems until the beginning of februari for just 1 project.
And we cannot figure out what the F is going on and why it SOMETIMES doesn't work ...
This helper function hasn't been changed, the dynamicweb dlls haven't changed and the xml file is valid.
It results in very ugly translate keys being shown on the website and in e-mails, so we really need to get this fixed.
Hopefully anyone can point us in the right direction after reading the following:
Our helper function retrieves the design and calls Dynamicweb.Rendering.Translation.Translation.GetTranslation(keyword, cultureInfo, design)
This GetTranslation returns the translation value for the entered keyword based on culturinfo from the xml file based on the design.
It has a fallback to return the keyword if no translation was found.
This dynamicweb function seems to be using a cached value as source, which makes a lot of sense.
Somehow we started getting keywords as output value, while those keywords did exist in the translation.xml and this xml file was valid.
After a while the problem went away, but it returns ones in a while.
We added extra logging in our helper function, which logs whenever the input value is equal to the output value.
At that moment we also log Dynamicweb.Rendering.Translation.Translation.GetTranslationKeys(KeyScope.DesignsLocal, design).Count, which indicates the number of translations available in the cached data.
There are many log lines that were expected, since a key vale can be the translation for one of the languages. In those cases the key count was 2085.
But then we also see log lines with obvious key names like DefaultMailTitle, which should be translate, but weren't! In those cases the key count was 0! (or a low number)
I guess in those cases the translate function was trying to get a translation from an empty cache file or something, which obviously doesn't work, so it returned the keyword.
And this gets automagically fixed at a point when the cache gets refilled by the origional xml document.
What we can't figure out is WHY the translation keys got flushed.
Is it something from the hosting environment?
I've tried to match appool recycles and eventviewer errors with the log times, but couldn't find a clear match.
Is there some additional logging available from DW functions to find out why this happens?
Is there a workaround?
Is there a better way to retrieve translations from c# code?
I can't really make a workaround on our side, since we can't know in which cases the return value should be equal to the input value and when it shouldn't.
I hope anyone can help me in this matter.