#25223: Setting LANGUAGE_CODE to a language that doesn't exist in
django/conf/locale raises IOError
-------------------------------------+-------------------------------------
Reporter: svleeuwen | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.8
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 beck):
Indeed. This is by design.
The reason is to catch broken django installs. If trying to activate a
supported language and the django translations are missing/unreadable
(referencing #18192), the framework needs to blowup and make the user
aware of the issue.
When trying to set the default language to one not supported by django,
this action has the same side-effects as activating a common language with
a broken install.
IMO catching a broken install is more critical and a more common use-case
than setting the default language to one (not yet) supported.
However, django will let you use and activate a custom language (just not
make it the default).
To exemplify:
1. Add a translation catalog for the custom language.
Add file `projectdir/locale/sd/LC_MESSAGES/django.po`:
{{{
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
msgid "butterfly"
msgstr "پوپَٽُ"
}}}
2. In settings.py add the locale and use a default language found in
[https://github.com/django/django/tree/master/django/conf/locale
django/conf]:
{{{
LANGUAGE_CODE = 'en'
LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]
}}}
3. Compile messages:
{{{
$ python manage.py compilemessages
processing file django.po in
/Users/doug/Desktop/project/locale/sd/LC_MESSAGES
}}}
4. Test the translation.
Create `test.py`:
{{{
from django.utils.translation import activate, ugettext
activate('sd-pk')
print ugettext('butterfly')
}}}
Run `test.py` through django shell:
{{{
$ python manage.py shell < test.py
(InteractiveConsole)
>>> پوپَٽُ
}}}
As for this ticket, since all is working by design I do not believe it to
be a bug.
This ticket could be reworded as a feature request:
Allow default language to be one unsupported by django if the local
project has the required translation catalog
Or open a new pull on django adding Sindhi :)
--
Ticket URL: <https://code.djangoproject.com/ticket/25223#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.dd2501c8065651e6e3d95da06d71eb5f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.