Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch language list of sitecore items

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

like image 465
user166013 Avatar asked Dec 28 '25 23:12

user166013


1 Answers

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();
like image 134
Marek Musielak Avatar answered Dec 31 '25 12:12

Marek Musielak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!