Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup email translation with Django Allauth

I am trying to setup translations for emails with django-allauth.
I have rewritten my templates, translated my .po files and complied them.

The html translations work fine but for some reason just the emails don't get translated.

I have properly configured translations following the django tutorial
https://docs.djangoproject.com/en/1.10/topics/i18n/translation/#how-django-discovers-language-preference

The related question doesn't help: How does email translation work with django allauth?

Package versions:
Django==1.10
django-allauth==0.27.0

like image 418
arosa Avatar asked Aug 26 '16 18:08

arosa


1 Answers

I had the same problem with django-allauth==0.32.0 and Django==1.11.1. Translations that are shipped with allauth are simply outdated or incomplete. In my project, for example, an email with a link to reset the password was always in English (in default language LANGUAGE_CODE = 'en') although the user set the language to Czech.

In .po file for Czech translations: https://github.com/pennersr/django-allauth/blob/master/allauth/locale/cs/LC_MESSAGES/django.po#L408 is this e-mail translation marked as fuzzy – so translations are not used. The same applies to other languages I've checked (de, es...).

The reason is explained in this comment from the author of allauth:

The allauth templates are merely meant as a starting point, something to get you going quickly. Hence, I do not treat issues in the translations as blocking for release, which can result in translations getting left behind. Feel free to submit pull requests to fill in the gaps.

Source: https://github.com/pennersr/django-allauth/issues/1113#issuecomment-141189606

I think there are two ways to solve this issue:

  1. Fix/update translations on https://www.transifex.com/django-allauth/django-allauth/, submit pull request on Github and wait for a new release.
  2. My recommendation: copy all templates from allauth to your project, make your own *.po files and ignore all default translations/templates. Do not forget that e-mail templates are in *.txt so you must call makemessages this way: python manage.py makemessages ... --extension html,txt,py.
like image 99
illagrenan Avatar answered Oct 11 '22 13:10

illagrenan