A
A
Alexander2016-04-27 09:25:03
Django
Alexander, 2016-04-27 09:25:03

How to set up multilingualism on the site?

settings.py:

LANGUAGE_CODE = 'kz'
USE_I18N = True
USE_L10N = True
ugettext = lambda s: s
LANGUAGES = [
    ('en', ugettext('English')),
]

added to urls.py :
urlpatterns += i18n_patterns(
    url(r'^$', "home.views.home", name="home"),
)

then ran the command django-admin.py makemessages -l en
then python3.5 manage.py runserver :
.....
 File "/usr/lib/python3.5/gettext.py", line 432, in translation
    raise OSError(ENOENT, 'No translation file found for domain', domain)
FileNotFoundError: [Errno 2] No translation file found for domain: 'django'

I understand that I have to add something somewhere.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-04-28
@kentuck1213

Eh, I spent 2 days on an elementary thing, resentment ((.
the essence of the problem was this, in projects/locale/kz/LC_MESSAGES there is a django.po file
inside it is "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\ n" should have spotted it on "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ?1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
"%100> =11 && n%100<=14)? 2 : 3);\n"
followed by
python3.5 manage.py compilemessages

N
Nikolay Korotkiy, 2016-04-27
@sikmir

django-admin.py compilemessages
And we read How Django discovers language preference more carefully , everything is described there in as much detail as possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question