Developer forum

Forum » Development » Frontend translation in OrderComplete notification

Frontend translation in OrderComplete notification

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

We are trying to create an order complete and at that time, we need to append some strings (orderline custom field in my case, but could just as easily be an order custom field), that we then need to use in the email notification and "My order details".

 

The challenge is that we want to control the string via Translate tags (should not be hardcoded in the dll). I know that trying to use Dynamicweb.SystemTools.Translator.Translate() throws some expections, so how can I achieve this instead?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Translate methods are very depending on the context - and this one is UI translations and would and should not run in the frontend.

Translations are meant to run in .aspx files for backend or cshtml files in frontend. Not in code classes.

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Sure, I understand, so what alternative do I have? Should we be saving/updating the order custom field in the frontend, and in the Notification subscriber deleting it if it became stale? That's messy too.

 

In this case we simply just need to apply/store data after the order has been placed, and would like to use the frontend language, so it's an "exception" of wanting to use that. I guess I can manually load the translations XML file and traverse through it, if that's the best way to do that.

 

Any thoughts on that?

Nuno

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Call @Translate in the template.

Or call the frontend translation API in Dynamicweb.Rendering.Translation.Translation.GetTranslation

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Ah... the frontend translation API would make sense for us. Thanks a lot

 

You must be logged in to post in the forum