Search code examples
umbracoumbraco7

How to instantiate LocalizationService in Umbraco.Core in version 7.5.4


Hi I wanted to get all the languages in my Umbraco CMS using LocalizationService().GetAllLanguages() but it seems LocalizationService() has changed in Umbraco 7.5.4 and are asking for mandatory parameters.

How do I properly instantiate LocalizationService()?

public LocalizationService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory)

Solution

  • You don't have to instantiate it, it's a singleton in ApplicationContext.Current.Services

    So you can do: Services.LocalizationService.GetAllLanguages()