2

We have a multilingual website and using language fallback(Item Level). I am finding hard to get the fallback language of an item.

We have fr-FR which is falling back to en-FR. But when I get the item in fr-FR and check for

LangugaeFallbackEnabled field is false

I could not find any other fields specifying this information.

I have double checked in Sitecore it's falling back to en-FR.

What's the best way to check for the fallback language of an item?

Sitecore Version - 8.1 update 3

  • With language fallback, accessing the item in the language that is falling back should give the item in the fallback language without any extra checks. Is that not working or are you trying to check if the item is falling back vs not for a specific reason? – Teeknow Aug 29 '17 at 15:33
  • Its giving me the item in falling back language. I am trying to check if item is falling back because I need to execute some logic if it is. – Dheeraj Palagiri Aug 29 '17 at 15:41
2

To check if an item you are accessing is a fallback use the IsFallback property: Sitecore.Data.Items.Item.IsFallback. To get the actual language being used you could use the method Sitecore.Data.Items.Item.GetFallbackItem() and check the language on that.

It's possible that you could do this more efficiently while looking at that method by using the language fallback manager: Sitecore.Data.Managers.LanguageFallbackManager.GetFallbackLanguage(Language language, Database database, ID relatedItemId).

  • Is there a way to find which language it is falling back to? – Dheeraj Palagiri Aug 29 '17 at 15:46
  • You can try using this method: Sitecore.Data.Items.Item.GetFallbackItem(). Then you would check the Language property of what that returns. I have updated my answer to include that. – Teeknow Aug 29 '17 at 15:57
  • Actually, that did not help, isFallback property is false and GetFallBackItem is null? – Dheeraj Palagiri Aug 29 '17 at 16:05
  • @DheerajPalagiri can you verify that accessing the item while your context language is set to the language that does not have a version has its fields filled with the content of the language it falls back to? Another thing I would like you to try running is the following: Sitecore.Data.Managers.LanguageFallbackManager.GetFallbackLanguage(Language language, Database database). This should return your fallback language. If it does not then I believe there is an issue with how that is configured (/sitecore/system/Languages). – Teeknow Aug 29 '17 at 16:11
  • 1
    Alright sounds good. If the linked question doesn't help out feel free to post a new question focused on your issue. – Teeknow Aug 29 '17 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.