I am building an application with ASP.NET Core 5.0 following DDD and the CQRS pattern. I internationalize on the presentational layer but when I send emails I send them in the application layer via an email sender service. This service doesnt know anything about internationalization because I have that capsuled on the presentational layer. So my question is how do I get internationalized emails in my application layer / email sender service, what is the best approach?

Edit: In my current example I am trying to register a user and sending a verfication email. So I am dispatching a createUser command on the presentational layer (a Web Rest API) to my application layer. I create the user and use an email sender service. The content of the email has to be in the users language. I don't think that sending that email needs to be moved to the presentational layer.

If you need code excerpts let me know.

  • Without knowing anything else about your application, I'd say what you need to do is add localization to your email sender service. How you do that is entirely up to you. If you think you can commandeer your "presentation layer" to do that, by all means. Otherwise, it's simply a matter of adding the necessary code to your email sender service. Sep 9, 2021 at 13:16
  • Wording and formatting emails belongs in the presentation layer. The technical details of sending them are akin to the technical details of the web server that you use - not really relevant to your application design, just part of the infrastructure. Sep 9, 2021 at 13:53
  • Why do you want the emails localized in your application layer? What's wrong with having "localization capsuled on the presentational layer"? Sep 9, 2021 at 15:37
  • @Hans-MartinMosner while I’d agree with this statement in some cases, it seems challengeable in general. What if the localized email content is business related (e.g. using product names in several languages, which means a multilingual business process and a domain model coping with multilingual data). What if the email content is defined according to localized rules (e.g.with different thresholds depending on currency or country of the receiving party)?
    – Christophe
    Sep 9, 2021 at 16:19
  • Carlos, can you clarify if it’s about localization or internationalization, and the reason you think it does not belong to presentation layer? And can you tell more about your email localization, e.g. is it mainly about translation or are there also other concerns?
    – Christophe
    Sep 9, 2021 at 16:43

2 Answers 2


Did you mean layers or tiers?

Tiers are independent processes or components that may potentially run on different processing nodes. The usual ones are presentation (front-end), application, and database. They are often called "layer" because of the graphical representation, but it’s about distribution of components.

The internal structure may also be organized in layers, according to some split of responsibilities. The naming of those layers depend on the authors but have similar names than the tiers (e.g. presentation, business/application, DAL).

This might create confusion, as internal layers do not necessarily correspond one-to-one with the distribution components. We can agree that email localization cannot run on the presentation tier (front-end).

How to solve it?

Your registration process needs to know the email address of the user for sending the mail. But it also needs to know the language to use since the backend has other language parameters:

  • You need to pass language information from the front-end (where it is known, either asking it from the user or taking it from the environment preferences) to the back-end (where it is needed). The best way to do this, is to pass it along with the email address to used.
  • The email content is just standard text in the user's language (now know to the back-end) and does not involve any domain logic for composing it. It seems therefore that generating it, would still belong to the part of the presentation logic, even if running on the backend.

At the higher layer, don’t send an email. Send a description of the contents of the email, and write a small layer that takes the description, translates it into English, and sends the email. That part is called “internationalisation”.

Now you get a good French speaker, a good German speaker etc. who can take your email description and write code to translate it into French, German etc. Obviously you would do a translation that is mostly table driven, so as far as possible the changes are just in some table.

(Currencies are interesting, because there is currency and user language. A German living in the UK might get a bill for an amount of British pound, but written in German. Translating “please pay £100” into “bitte zahlen Sie 100 Euros” would be fatal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.