Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve a list of all enabled languages for the EPi Server website programmatically?

I simply want to get a list of all enabled languages for the EPi Server website (enabled in the "Manage Website Languages" panel in Admin mode) and preferably also be able to retrieve the path to the flag icon and of course the culture name/ID.

I'm using EPiServer 6 R2 so if the code works for that version it would be lovely. Pointing me in the right direction would be great too.

like image 748
kjetilh Avatar asked Oct 15 '13 07:10

kjetilh


1 Answers

You mean

ServiceLocator.Current.GetInstance<ILanguageBranchRepository>().ListEnabled();

However you should really not be using the ServiceLocator at all and instead take a ILanguageBranchRepository as a constructor parameter that will be automatically resolved by StructureMap. This gives your class a clear list of its dependencies and makes unit testing it a lot easier as you don't have to mock the ServiceLocator.

like image 125
Tommy Ivarsson Avatar answered Oct 27 '22 03:10

Tommy Ivarsson