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); }
Comments
Post a Comment