Template for Password Reset Email
Hi,
I have a list and user account set with French as the preferred language.
Most message emails (such as the Welcome email) all arrive in French, but not the Password Reset email (shown below) - it arrives in English.
I'm guessing that there may not be an .mo file for it.
I don't see a template for the Password Reset email in the list's administration settings.
Is it possible to create a template for it? Something like "list:user:action:reset"?
My thinking is, if creating a template is possible, to (a) write it in French for this list; and (b) rewrite it differently as it's confusing some users.
Regards, Mark
Subject: [lists.domain.com] Password Reset Email
Hello from lists.domain.com!
You are receiving this email because you or someone else has requested a password for your user account. However, we do not have any record of a user with email imark@myemail.com in our database.
This mail can be safely ignored if you did not request a password reset.
If it was you, you can sign up for an account using the link below.
https://lists.domain.com/accounts/signup/
Thank you for using lists.domain.com! lists.domain.com
On 11/14/24 13:57, Mark wrote:
I have a list and user account set with French as the preferred language.
Most message emails (such as the Welcome email) all arrive in French, but not the Password Reset email (shown below) - it arrives in English.
I'm guessing that there may not be an .mo file for it.
This message comes from django-allauth. there is a French message
catalog for it. These are in site-packages/allauth/locale/fr/LC_MESSAGES
and should be good. You can always run django-admin compilemessages
to
update all the .mo files for all the projects.
However, the issue is probably that Django doesn't get the language context from the list's preferred language. In fact, the password reset is not in a list context at all. See https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#how-django-di... for how it determines the language to serve.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 2024-11-14 23:58, Mark Sapiro wrote:
On 11/14/24 13:57, Mark wrote:
Most message emails (such as the Welcome email) all arrive in French, but not the Password Reset email (shown below) - it arrives in English.
This message comes from django-allauth. there is a French message catalog for it. These are in site-packages/allauth/locale/fr/LC_MESSAGES and should be good. You can always run
django-admin compilemessages
to update all the .mo files for all the projects.
I can see the French text for the "Password Reset Email" in the django.po file. And running the compilemessages command reports the "django.po" for French is okay and up to date. Should I be recompiling the ".mo" file?
cd /opt/mailman/venv/lib/python3.11/site-packages/allauth (venv) ... $ django-admin compilemessagespwd ... File “/opt/mailman/venv/lib/python3.11/site-packages/allauth/locale/fr/LC_MESSAGES/django.po” is already compiled and up to date. ...
However, the issue is probably that Django doesn't get the language context from the list's preferred language. In fact, the password reset is not in a list context at all. See https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#how-django-di... for how it determines the language to serve.
I'm afraid I don't understand the Django documentation. It seems to be referring to site-wide settings for language, and not "per list".
On 11/17/24 16:57, Mark wrote:
I can see the French text for the "Password Reset Email" in the django.po file. And running the compilemessages command reports the "django.po" for French is okay and up to date. Should I be recompiling the ".mo" file?
No, It's fine. The issue is the language context for this message has nothing to do with any Mailman list's preferred language.
Again, see https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#how-django-di...
If all the lists on your server are French, you could set
LANGUAGE_CODE = 'fr'
in your Django settings. Otherwise, the user's browser has to include an Accept-Language: header specifying French as the most preferred language in it's request.
Also note the ordering of SessionMiddleware, LocaleMiddleware and CommonMiddleware in the above doc. I have recently updated the various places where we suggest or supply MIDDLEWARE settings, but you may find that your settings have LocaleMiddleware after CommonMiddleware and you should fix that.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 2024-11-18 01:38, Mark Sapiro wrote:
On 11/17/24 16:57, Mark wrote:
I can see the French text for the "Password Reset Email" in the django.po file. And running the compilemessages command reports the "django.po" for French is okay and up to date. Should I be recompiling the ".mo" file?
No, It's fine. The issue is the language context for this message has nothing to do with any Mailman list's preferred language.
Again, see https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#how-django-di...
If all the lists on your server are French, you could set
LANGUAGE_CODE = 'fr'
in your Django settings. Otherwise, the user's browser has to include an Accept-Language: header specifying French as the most preferred language in it's request.
Also note the ordering of SessionMiddleware, LocaleMiddleware and CommonMiddleware in the above doc. I have recently updated the various places where we suggest or supply MIDDLEWARE settings, but you may find that your settings have LocaleMiddleware after CommonMiddleware and you should fix that.
It's just the one list that is using French. Others are in English
I've edited the order of the middleware settings in this file ...
/opt/mailman/venv/lib/python3.11/site-packages/mailman_web/settings/base.py
I reordered as below, restarted everything but no joy :-(
... at Line 76 ... MIDDLEWARE = ( 'allauth.account.middleware.AccountMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django_mailman3.middleware.TimezoneMiddleware', 'postorius.middleware.PostoriusMiddleware', ) ...
I'm thinking this is not the file I'm looking for. Apologies for my cluelessness here.
On 11/17/24 21:27, Mark wrote:
It's just the one list that is using French. Others are in English
I've edited the order of the middleware settings in this file ...
/opt/mailman/venv/lib/python3.11/site-packages/mailman_web/settings/base.py
I reordered as below, restarted everything but no joy :-(
Your reording is fine.
I'm thinking this is not the file I'm looking for. Apologies for my cluelessness here.
You have done everything correctly. What is missing is the user's
browser is not putting fr
first in the Accept-Language: HTTP header in
it's requests.
Most browsers have a setting to control this.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 2024-11-18 16:23, Mark Sapiro wrote:
On 11/17/24 21:27, Mark wrote:
You have done everything correctly. What is missing is the user's browser is not putting
fr
first in the Accept-Language: HTTP header in it's requests.Most browsers have a setting to control this.
Gotcha. Wow! That was a suprise. Here I was thinking that there was no way the browser's setting would have any effect on the email.
But now I see how it all works. Brilliant!
Thank you once again Mark. Your patience and guidance are truly appreciated.
Best, Mark
participants (2)
-
Mark
-
Mark Sapiro