Question

I have items created in various languages in sitecore. I need to fetch the list of languages in which that item is created. Example: If available languages in sitecore are : en,de,fr,it,en-GB. But the item is created in only en and de, i need to have list of languages as en and de. can someone provide me the piece of code for obtaining that.

Thanks

Was it helpful?

Solution

Item class has a property called Languages which returns list of languages that the item has content in.

Sitecore.Globalization.Language[] langs = item.Languages;

and if you need just string list with names of the languages you can use:

List<string> langNames = item.Languages.Select(l => l.Name).ToList();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top