This article has not yet been verified against Umbraco 8.

    The concepts and code examples might not work if you are running Umbraco 8.0 or a later version. If you are using Umbraco 7, this article is perfect for you!

    You are more than welcome to report any issues found on the Documentation Issue Tracker.

    LocalizationService

    Applies to Umbraco 6.0.0+

    The LocalizationService acts as a "gateway" to Umbraco data for operations which are related to Dictionary items and Languages.

    Browse the API documentation for LocalizationService.

    • Namespace: Umbraco.Core.Services
    • Assembly: Umbraco.Core.dll

    All samples in this document will require references to the following dll:

    • Umbraco.Core.dll

    All samples in this document will require the following using statements:

    using Umbraco.Core;
    using Umbraco.Core.Models;
    using Umbraco.Core.Services;
    

    Getting the service

    If you wish to use use the localization service in a class that inherits from one of the Umbraco base classes (eg. SurfaceController, UmbracoApiController or UmbracoAuthorizedApiController), you can access the localization service through a local Services property:

    ILocalizationService localizationService = Services.LocalizationService;
    

    In Razor views, you can access the localization service through the ApplicationContext property:

    ILocalizationService localizationService = ApplicationContext.Services.LocalizationService;
    

    If neither a Services property or a ApplicationContext property is available, you can also reference the ApplicationContext class directly and using the static Current property:

    ApplicationContext.Current.Services.LocalizationService
    

    Samples

    • Retrieving languages
      See examples on how to retrieve languages via the localization service - either individually or as a collection.