Search code examples
umbracomultilingualumbraco5

Umbraco.getDictionaryItem Helper in Custom Controller


Can i access @Umbraco.getDictionaryItem Helper in my Custom Controller in my custom Area and then add it to the model of the custom partial page which i am rendering through plain jquery Ajax. And also it would b great if i can access it in my Surface Controller plugin.

Thanks,

Sher


Solution

  • Create your custom controller as Surface Controller, and obtain the IRoutableRequestContext,

    public class propertydetailsController : SurfaceController
    {
        private IRoutableRequestContext _routableRequestContext;
    }
    

    then access the Dictionary helper class in Umbraco.Cms.Web.Dictionary, sample code is below.

    DictionaryHelper dictionaryHelper = new DictionaryHelper(_routableRequestContext.Application);
    string valueDictionary = dictionaryHelper.GetDictionaryItemValueForLanguage("DictionaryName", "en-GB");
    

    Cheers