In a solution with Item level language fallback enabled, how do I tell if this is in effect for the current item? I would like to set the html
element lang
attribute to the language that is being displayed.
For example, if Spanish is requested and a Spanish version exists, it should be set to lang='es'
. But if the item falls back to English, it should be set to lang='en'
.
I tried:
var language = Sitecore.Context.Item.Versions.Count > 0 ?
Sitecore.Context.Item.Language :
Sitecore.Context.Item.GetFallbackItem().Language;
But this always returns the requested language, as the count appears to be greater than zero due to Language fallback.