Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#24503 closed Bug (fixed)

Misleading doc regarding language_code fallback

Reported by: pascal chambon Owned by: nobody
Component: Internationalization Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by pascal chambon)

The docs state that LANGUAGE_CODE will be used as fallback if a specific string has no translation in the active request language (https://docs.djangoproject.com/en/1.7/ref/settings/#language-code).

However, my tests and my exploration of "real_trans.py" suggest that LANGUAGE_CODE is only used as a global fallback if the whole selected language is missing. Per-string fallback doesn't work it seems, on django <=1.7 at least (on current dev branch, lots of stuffs have moved in that code, so it seems a real fallback is getting implemented).

Example of a test output:

2015-03-18_14:48:34 UTC - INFO - <722724742146458> Language active for request: 'de' (LANGUAGE_CODE: 'fr-FR')

Translated string received : "'invalid input parameters'" (so no translation occurred)

When forcing active language to fr or fr-FR, the string is properly translated to "Paramètres invalides" in french.

Is that a bug of django, an error in the docs, or an error on my side ? I may provide a patch to fix django<=1.7 docs, if it occurs that per-string language fallback was actually never implemented yet.

Attachments (2)

0001-Correct-LANGUAGE_CODE-doc-for-django-1.7.patch (1017 bytes ) - added by pascal chambon 10 years ago.
24503.diff (910 bytes ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by pascal chambon, 10 years ago

Description: modified (diff)

comment:2 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedAccepted

You are right, this is fixed in Django 1.8/master. Documentation patch welcome.

comment:3 by pascal chambon, 10 years ago

Attached is a patch for django <= 1.7,

regarding the patching of 1.8 docs, I don't know what the status is exactly (work in progress ? followed in another ticket ?), I guess the person(s) refactoring i18n will be best placed to update the doc, below is just a draft sample in case it helps.

.. versionchanged:: 1.8

  The ``LANGUAGE_CODE`` is now  also used to provide a fallback translation, 
  when no translation exists for a given literal in the user's preferred language.

comment:4 by pascal chambon, 10 years ago

Has patch: set

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In b2a80f9:

[1.7.x] Fixed #24503 -- Corrected docs on how LANGUAGE_CODE works as a fallback.

comment:6 by Tim Graham, 10 years ago

Resolution: fixed
Status: closednew

Adding a patch for master/1.8 for Claude's review.

by Tim Graham, 10 years ago

Attachment: 24503.diff added

comment:7 by Claude Paroz, 10 years ago

Triage Stage: AcceptedReady for checkin

LGTM

comment:8 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 8219eabb:

Fixed #24503 -- Added docs on LANGUAGE_CODE fallback change in 1.8.

Thanks Pakal and Claude.

comment:9 by Tim Graham <timograham@…>, 10 years ago

In 5cd55140:

[1.8.x] Fixed #24503 -- Added docs on LANGUAGE_CODE fallback change in 1.8.

Thanks Pakal and Claude.

Backport of 8219eabbba6e8f6d8569792615935011b5cf0771 from master

comment:10 by Claude Paroz <claude@…>, 9 years ago

In 1046c8af:

Fixed #24739 -- Documented translation fallback change

Refs #24503.

comment:11 by Claude Paroz <claude@…>, 9 years ago

In 7915cbb:

[1.8.x] Fixed #24739 -- Documented translation fallback change

Refs #24503.
Backport of 1046c8afec from master.

Note: See TracTickets for help on using tickets.
Back to Top