[Django] #25915: Error when using a language that Django doesn't ship translations for

4 views
Skip to first unread message

Django

unread,
Dec 10, 2015, 6:50:06 PM12/10/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
--------------------------------------+--------------------
Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: Internationalization | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
I am trying to add translations for a new language (that Django doesn't
support) to my project. Let's say it has the language code `xxx` for
example.

I make the .po file with

{{{
./manage.py makemessages -l xxx
}}}

Then I translate the po file and compile it. When I set `LANGUAGE_CODE =
'xxx'` and run runserver, Django fails with:


{{{
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "django/core/management/__init__.py", line 350, in
execute_from_command_line
utility.execute()
File "django/core/management/__init__.py", line 324, in execute
django.setup()
File "django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "it__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in
_call_with_frames_removed
File "foo/models.py", line 381, in <module>
MinLengthValidator(22, _("This value must be at least 22 digits.")),
File "django/core/validators.py", line 297, in __init__
if message:
File "django/utils/functional.py", line 109, in __wrapper__
res = func(*self.__args, **self.__kw)
File "django/utils/translation/__init__.py", line 85, in ugettext
return _trans.ugettext(message)
File "django/utils/translation/trans_real.py", line 313, in gettext
return do_translate(message, 'gettext')
File "django/utils/translation/trans_real.py", line 296, in do_translate
_default = _default or translation(settings.LANGUAGE_CODE)
File "django/utils/translation/trans_real.py", line 203, in translation
_translations[language] = DjangoTranslation(language)
File "django/utils/translation/trans_real.py", line 112, in __init__
self._init_translation_catalog()
File "django/utils/translation/trans_real.py", line 150, in
_init_translation_catalog
translation = self._new_gnu_trans(localedir, use_null_fallback)
File "django/utils/translation/trans_real.py", line 133, in
_new_gnu_trans
fallback=use_null_fallback)
File "/usr/lib/python3.4/gettext.py", line 419, in translation
raise OSError(ENOENT, 'No translation file found for domain', domain)
FileNotFoundError: [Errno 2] No translation file found for domain:
'django'
}}}


It seems that this errors happens whenever you try to use a language that
doesn't have a django.po shipped with django (in `django/conf/locale/`).
Shouldn't I be able to provide the translations just in my project?

--
Ticket URL: <https://code.djangoproject.com/ticket/25915>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 14, 2015, 7:24:19 PM12/14/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Maybe you need to add it to `settings.LANGUAGES` too?

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:1>

Django

unread,
Dec 14, 2015, 7:29:02 PM12/14/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by gavinwahl):

It happens whether or not the language is in `LANGUAGES`.

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:2>

Django

unread,
Dec 14, 2015, 7:58:20 PM12/14/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

Could you provide a minimal project to reproduce or a test case for the
Django test suite?

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:3>

Django

unread,
Dec 14, 2015, 8:17:04 PM12/14/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 1.9
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by gavinwahl):

<https://github.com/fusionbox/bug-25915-test>

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:4>

Django

unread,
Dec 18, 2015, 8:35:49 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
--------------------------------------+------------------------------------
Reporter: gavinwahl | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* version: 1.9 => 1.8
* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Bisected to a5f6cbce07b5f3ab48d931e3fd1883c757fb9b45 (previously no error
when running `manage.py check` with the sample project before that commit)

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:5>

Django

unread,
Dec 18, 2015, 10:03:21 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
--------------------------------------+------------------------------------
Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: assigned

Component: Internationalization | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* owner: nobody => claudep
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:6>

Django

unread,
Dec 18, 2015, 11:20:05 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
--------------------------------------+------------------------------------
Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: assigned
Component: Internationalization | Version: 1.8
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by claudep):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/5840 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:7>

Django

unread,
Dec 18, 2015, 11:41:45 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------

Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: assigned
Component: | Version: 1.8
Internationalization |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:8>

Django

unread,
Dec 18, 2015, 11:51:15 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------
Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: closed
Component: | Version: 1.8
Internationalization |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"cd3c042b0473e762b0e89bc69a9244c4a1fed66e" cd3c042]:
{{{
#!CommitTicketReference repository=""
revision="cd3c042b0473e762b0e89bc69a9244c4a1fed66e"
Fixed #25915 -- Allowed language not in Django's default LANGUAGES

This fixes a regression introduced by a5f6cbce07.
Thanks Gavin Wahl for the report and Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:9>

Django

unread,
Dec 18, 2015, 11:52:36 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------
Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: closed
Component: | Version: 1.8
Internationalization |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"f0a4ff2b118cbc3b7f9ac28a7d9e355288b546c0" f0a4ff2]:
{{{
#!CommitTicketReference repository=""
revision="f0a4ff2b118cbc3b7f9ac28a7d9e355288b546c0"
[1.9.x] Fixed #25915 -- Allowed language not in Django's default LANGUAGES

This fixes a regression introduced by a5f6cbce07.
Thanks Gavin Wahl for the report and Tim Graham for the review.

Backport of cd3c042b0 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:10>

Django

unread,
Dec 18, 2015, 11:54:21 AM12/18/15
to django-...@googlegroups.com
#25915: Error when using a language that Django doesn't ship translations for
-------------------------------------+-------------------------------------
Reporter: gavinwahl | Owner: claudep
Type: Bug | Status: closed
Component: | Version: 1.8
Internationalization |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"67a62703cc8ade30df875ec272113cc157c067f0" 67a62703]:
{{{
#!CommitTicketReference repository=""
revision="67a62703cc8ade30df875ec272113cc157c067f0"
[1.8.x] Fixed #25915 -- Allowed language not in Django's default LANGUAGES

This fixes a regression introduced by a5f6cbce07.
Thanks Gavin Wahl for the report and Tim Graham for the review.
Backport of cd3c042b0 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25915#comment:11>

Reply all
Reply to author
Forward
0 new messages