R
R
Ruslan Gilfanov2016-12-12 14:17:12
Django
Ruslan Gilfanov, 2016-12-12 14:17:12

Why doesn't translation of verbose_name work for applications of django-allauth package installed via pip?

The well-known battery for authorization through third-party services django-allauth is installed via pip into the project's virtual environment.
The translation of the verbose_name of the application does not work, while there is no such problem for verbose_name models:
b927ef2c85be4ff99be41ef18aa53c8c.png
Python and Django versions:

  • v. Python: 3.5.2
  • v. Django: 1.10.4

Everything looks correct in the application sources:
/ProjectEnv/lib/python3.5/site-packages/allauth/socialaccount/apps.py
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _

class SocialAccountConfig(AppConfig):
    name = 'allauth.socialaccount'
    verbose_name = _('Social Accounts')

/ProjectEnv/lib/python3.5/site-packages/allauth/socialaccount/__init__.py
from . import app_settings

default_app_config = 'allauth.socialaccount.apps.SocialAccountConfig'

/ProjectEnv/lib/python3.5/site-packages/allauth/locale/ru/LC_MESSAGES/django.po
#: socialaccount/apps.py:8
#, fuzzy
msgid "Social Accounts"
msgstr "Социальные аккаунты"

To be sure, here is an excerpt from the settings.py file of a project using django-allauth:
INSTALLED_APPS = [
    ...
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.vk',
    ...
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.i18n',
                ...
                'django.template.context_processors.request',
            ],
        },
    },
]

LANGUAGE_CODE = 'ru-ru'

As a crutch , you can forget about internationalization and explicitly override the verbose_name of applications in almost any project file:
from allauth import socialaccount

socialaccount.apps.SocialAccountConfig.verbose_name = 'Социальные аккаунты'

Perhaps someone has come across the selective work of the ugettext_lazy utility in popular third-party applications and found a more adequate solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Gilfanov, 2016-12-12
@ri_gilfanov

In localization files with the .po extension, some of the translated strings are marked fuzzy translation:
And ignored when compiling files with the .mo extension
.
or like this:
Result:
Thanks to sim3x for the exact reference in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question