-
-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add i18n support to mail templates #834
Comments
Sorry for the late reply - we have this on the radar but currently with a low priority. We want to avoid to have translations in ORY Kratos itself as those are always hard to get right. Instead, we think that mounting a directory with (translated) mail templates is smarter. What do you think? |
Yes, that's the idea I'm proposing. Use the Accept-Language http header to select the right template. It's already possible to mount your own e-mail templates, so all that's needed is that the template functionality add the language extension to the name of the template to get the right one, so it should be a very easy fix. |
Right, so the idea would be to add a language-dependent variable around here: https://github.com/ory/kratos/blob/master/courier/template/verification_valid.go#L29 I imagine something like:
One problem will be getting the language into this function as the struct currently does not receive the Another problem is that these emails sometimes are not generated as part of an user-initiated HTTP Request. One such example is sending an account recovery to a user as an administrator. Here, the This means that we would need some other way of identifying the user locale - probably via his/her traits. I don't really know yet what this would look like without compromising the identity model. Maybe a special trait? But how do we get that in this function then here? So there are some things to figure out, and I would really appreciate some help on this! :) |
Then, maybe a better solution would be to introduce a special request parameter, like |
Where would that request parameter be sent? What would be different from the I think a locale for the user is something ORY Kratos should somehow support. |
What about making the identity's traits available to the template? One can then determine the language however they want (e.g. |
Big brain, @zepatrik ! This would then mean that the template has the translation, not the file system:
(with the go specific templating instructions of course). |
@zepatrik I like the idea of having the traits available in the template. That would allow for further customization of emails based on the identity. However, having also different languages in the template itself could lead to problems maintaining the template, especially if you support many languages and use html to spice up the templates. @aeneasr So, returning to the issue of using http header or request parameter, I had a very quick look (hope I'm not missing anything relevant) at the code, and starting at
Line 74 in 79d6a46
I haven't looked at the other scenarios, such as the verification flow, but I assume they are similar? So, to sum it up, the ideal solution, in my mind, would be to have both solutions, language header or parameter controlling the template to select, and traits available to customize the content in the template, like greeting with name of the receiver, etc. |
Hm right, but you can add the header to the traits yourself on signup/login/... In case of the admin API there would be no such language header, or you would have to set it accordingly. |
Our users don't perform self-service sign-up, they are all created using the Admin API, but yes, your right, there will be different ways people would want to handle this. However, using the traits would require the need to standardize the traits and as @aeneasr pointed out above, that could potentially compromise the identity model. However, if you're willing to dig into the model, the solution would be quite transparent, which would be nice for the sake of solving this use-case. |
I don't get why this would compromise the identity model. I would like to do:
and set the Or set the trait |
It would solve our current problem, yes 👍 |
Is your feature request related to a problem? Please describe.
Currently, it's not possible to have mail templates for different languages.
Describe the solution you'd like
Make the Recovery Flow with Link Method i18n-aware.
Describe alternatives you've considered
The Complete Recovery Flow with Link Method REST endpoint should accept and honor the standard
Accept-Language
HTTP header and use it to select the appropriate mail template.Additional context
N/A
The text was updated successfully, but these errors were encountered: