localization - Umbraco 5 Localize text in Surface Controller -


i've created newsletter subscription form in umbraco 5 using surface controller. controller renders form input fields user. when translate text in view works fine. can use:

umbraco.getdictionaryitem("newslettertitle") 

or

@("newslettertitle".localize()) 

when handle form submit need send localized email. localizing text doesn't work: example:

            var mail = new mailmessage();         mail.from = new mailaddress(settings.smtp.from);         mail.to.add(asubscriber.email);         mail.subject = "newslettersucces".localize(); 

the subject of mail = (umbraco.cms.web.newslettersucces). no localization. same happens when use getdictionaryitem("newslettersuccess"). advice appreciated.

you can push umbraco helper in view need umbraco.getdictionaryitem. created basesurfacecontroller like:

public class basesurfacecontroller : surfacecontroller    {     public umbracohelper umbraco{         {            irendermodelfactory modelfactory = dependencyresolver.current.getservice<irendermodelfactory>();             return new umbracohelper(this.controllercontext, this.routablerequestcontext, modelfactory);         }     } }  

and base viewmodel:

    public class baseviewmodel     {         public umbracohelper umbraco { get; set; }     } 

example:

    [childactiononly]     public partialviewresult contactform()      {         var model = new contactviewmodel();         model.umbraco = this.umbraco;          return partialview(model);      } 

source: http://our.umbraco.org/forum/core/umbraco-5-general-discussion/29601-mvc-form-localization-viewmodel-plus-umbraco-dictionaryitem


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -