openwisp/openwisp-users

[feature] Add user preferred language field

Closed this issue · 1 comments

We need to store an additional field to store the preferred language of the user (string, with choices defaulting to settings.LANGUAGES, defaulting to a callable which uses the default locale set in django settings).

This is needed because in different modules we send email to users and in some end-user applications we need to translate the content for the end users, and when sending email we don't have HTTP requests which tell us which languages are accepted by the user so we need to have this info stored in the DB.

Something like the following should do:

language = models.CharField(
    max_length=10,
    choices=settings.LANGUAGES,
    default=settings.LANGUAGE_CODE
)

Let's ensure the migration created points the choices directly to settings.LANGUAGES without duplicating the whole list/tuple, otherwise it will be painful to maintain.

I think this can be closed for now as it's not really needed.