https://supertokens.com/ logo
Title
r

romixch

12/22/2022, 12:42 PM
Hello again I would like to translate the emails that supertokens sends to our customers. I understand that I can change the content as described here: https://supertokens.com/docs/emailpassword/email-delivery/smtp/change-email-content But how do I know into which language I have to translate? I would be happy to get the language that users saw as they register in the browser.
The input to
getContent
contains a user and a userContext. Can I use those? How can I modify them at the registration screen?
j

jscyo

12/22/2022, 12:47 PM
Hey @romixch maybe @porcellus can help
r

romixch

12/22/2022, 12:51 PM
That would be excellent!
p

porcellus

12/22/2022, 1:06 PM
Hi
This could be a bit more involved: - we don't save the browser language information about the user - modifying the
userContext
on the frontend will not affect the backend.
you can use the user object to access your own database, where you could save the language the user is using during signup
Using the
preAPIHook
on the frontend, you can add this information into the sign up request
r

romixch

12/22/2022, 1:11 PM
Ok. The preAPIHook ist what I am looking at right now. So seams to be a good place.
p

porcellus

12/22/2022, 1:11 PM
Then, on the backend you can override the sign up API to get this information from the request and save it
r

romixch

12/22/2022, 1:11 PM
So I could for example set an additional header at the proAPIHook with the language?
Can I save it to the users metadata and get that at the email composition hook?
p

porcellus

12/22/2022, 1:14 PM
that works 🙂
r

romixch

12/22/2022, 1:15 PM
Nice. I will try it this way.
Although I could imagine a simpler interface for translation
Sorry to bother you again. So I've got the header set now in the preAPIHook from EmailPasswordReact.init. I see it traveling over the wire when sending a POST to "signup". But how can I see it at the other end? I don't see where I can access request headers.
@porcellus
p

porcellus

12/22/2022, 5:03 PM
oh, sorry for the late answer
you can override the sign up API
Yeah, we do not really save information like this about the user by default. The flow of adding extra info like this could be simpler, that's for sure.
r

romixch

12/23/2022, 3:47 PM
So that worked well. I am getting now used to the concepts too. I think I have now a good solution for Sign-up, verify, reset password. All translated. I still think supertokens was the right choice.