[Django] #24503: Misleading doc regarding language_code fallback

5 views
Skip to first unread message

Django

unread,
Mar 18, 2015, 10:06:53 AM3/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+--------------------
Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
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 ertror on my side ? I
may provide a patch to fix django<=1.7 docs, if it occurs that per-string
language was actually never implemented.

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

Django

unread,
Mar 18, 2015, 10:07:40 AM3/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.7
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 pakal):

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


Old description:

> 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 ertror on my side ?
> I may provide a patch to fix django<=1.7 docs, if it occurs that per-

> string language was actually never implemented.

New description:

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.

--

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

Django

unread,
Mar 18, 2015, 3:00:54 PM3/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | 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):

* stage: Unreviewed => Accepted


Comment:

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

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

Django

unread,
Mar 18, 2015, 3:50:09 PM3/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | 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 pakal):

* Attachment "0001-Correct-LANGUAGE_CODE-doc-for-django-1.7.patch" added.

Django

unread,
Mar 18, 2015, 3:54:33 PM3/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by pakal):

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.
}}}

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

Django

unread,
Mar 20, 2015, 7:48:53 AM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | 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 pakal):

* has_patch: 0 => 1


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

Django

unread,
Mar 20, 2015, 8:30:06 AM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------
Reporter: pakal | Owner: nobody
Type: Bug | Status: closed
Component: Internationalization | Version: 1.7
Severity: Normal | Resolution: fixed

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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"b2a80f9053acb151a753a3a1e264a65ab8a5d806" b2a80f9]:
{{{
#!CommitTicketReference repository=""
revision="b2a80f9053acb151a753a3a1e264a65ab8a5d806"
[1.7.x] Fixed #24503 -- Corrected docs on how LANGUAGE_CODE works as a
fallback.
}}}

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

Django

unread,
Mar 20, 2015, 9:10:38 AM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | 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 timgraham):

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


Comment:

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

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

Django

unread,
Mar 20, 2015, 9:10:54 AM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
--------------------------------------+------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | 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 timgraham):

* Attachment "24503.diff" added.

Django

unread,
Mar 20, 2015, 11:47:03 AM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------

Reporter: pakal | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.7
Internationalization |
Severity: Normal | 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 claudep):

* stage: Accepted => Ready for checkin


Comment:

LGTM

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

Django

unread,
Mar 20, 2015, 12:10:15 PM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------
Reporter: pakal | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization |
Severity: Normal | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"8219eabbba6e8f6d8569792615935011b5cf0771" 8219eabb]:
{{{
#!CommitTicketReference repository=""
revision="8219eabbba6e8f6d8569792615935011b5cf0771"
Fixed #24503 -- Added docs on LANGUAGE_CODE fallback change in 1.8.

Thanks Pakal and Claude.
}}}

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

Django

unread,
Mar 20, 2015, 12:10:27 PM3/20/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------
Reporter: pakal | Owner: nobody

Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization |
Severity: Normal | 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 Tim Graham <timograham@…>):

In [changeset:"5cd551409e3f445a8c7cf59b8cf038d709607dec" 5cd55140]:
{{{
#!CommitTicketReference repository=""
revision="5cd551409e3f445a8c7cf59b8cf038d709607dec"
[1.8.x] Fixed #24503 -- Added docs on LANGUAGE_CODE fallback change in
1.8.

Thanks Pakal and Claude.

Backport of 8219eabbba6e8f6d8569792615935011b5cf0771 from master
}}}

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

Django

unread,
May 18, 2015, 12:40:54 PM5/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------
Reporter: pakal | Owner: nobody

Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization |
Severity: Normal | 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:"1046c8afecf719eee5a2aaa28b001e731f94100b" 1046c8af]:
{{{
#!CommitTicketReference repository=""
revision="1046c8afecf719eee5a2aaa28b001e731f94100b"
Fixed #24739 -- Documented translation fallback change

Refs #24503.
}}}

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

Django

unread,
May 18, 2015, 12:41:50 PM5/18/15
to django-...@googlegroups.com
#24503: Misleading doc regarding language_code fallback
-------------------------------------+-------------------------------------
Reporter: pakal | Owner: nobody

Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization |
Severity: Normal | 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:"7915cbb360afd363bf94b31aa42b32387c302dea" 7915cbb]:
{{{
#!CommitTicketReference repository=""
revision="7915cbb360afd363bf94b31aa42b32387c302dea"
[1.8.x] Fixed #24739 -- Documented translation fallback change

Refs #24503.
Backport of 1046c8afec from master.
}}}

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

Reply all
Reply to author
Forward
0 new messages