Localise system emails on the fly or programatically control them from cloud code

I am using parse-server-api-mail-adapter for mailgun emails (one of the mailgun ones are using an outdated lib now and dont work and the other one im not sure why it doesnt work).

I allow users to change language on the fly during registration and pre-login - is there any way to localise these emails from a parameter provided an the UI level or maybe some way to programatically send a specific template via cloud code with the required system information like reset link etc ?

  • To set the language of the email template you could use the mail adapter’s localeCallback.
  • To set the language of the pages of any HTML form (password reset, etc.) you could use pages.

Perfect, I wasnt sure if localeCallback was only for custom emails, so it also controls the parse system emails ?

Yes it should. The template definition is the same, regardless of whether it’s built-in or custom.

1 Like

Hey Manuel,

Can you please help me understand how to use locales? I can’t figure it out for hours.

Here is my setup:

emailAdapter: {
      module: "parse-server-api-mail-adapter",
      options: {
        sender: process.env.EMAIL_FROM_ADDRESS,
        templates: emailTemplates,
        localeCallback: async () => {
          return "tr-TR";

        apiCallback: async ({ payload, locale }) => {
          const awsSesPayload = ApiPayloadConverter.awsSes(payload);
          const command = new SendEmailCommand(awsSesPayload);
          await sesClient.send(command);

I don’t understand how is localeCallback supposed to get the locale of the user? Do I write a parse query in the callback to get it from db? And when I get it how the adapter is supposed to use it? I can’t see any locale-specific logic.

Also, I tried to make the localeCallback return a locale that I have (tr-TR), for testing purposes, but it didn’t work, I still get English versions, even though I’ve structured my files as described in the docs.


Can you please explain to me like I’m 5 what needs to be done?

Thank you

@andreisu Please take a look at the docs. There is an example.

1 Like

Ok, my problem was that I was adding the localeCallback to the adapter config, when it should be in the specific emails template config. Thanks for the example.

  contactFormMessageAck: {

    localeCallback: async () => {
      //logic here

Yes, I made this design decision because different templates may require different ways of determining the locale.