Opened 9 years ago

Closed 8 years ago

#7061 closed (fixed)

i18n docs contradict actual RequestContext behavior

Reported by: Antti Kaihola Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The i18n.txt documentation says (bold mine):

Each RequestContext has access to three translation-specific variables:

  • LANGUAGES is a list of tuples in which the first element is the language code and the second is the language name (in that language).

However, the languages name seem to actually be in English (with default settings). When this test script is run:

from django.conf import settings
from django.template import RequestContext
print '\n'.join('%-5s %s' % l for l in RequestContext(None)['LANGUAGES'])

this is what is output on the terminal:

ar    Arabic
bn    Bengali
bg    Bulgarian
ca    Catalan
cs    Czech
cy    Welsh
da    Danish
de    German
el    Greek
en    English
es    Spanish
es-ar Argentinean Spanish
eu    Basque
fa    Persian
fi    Finnish
fr    French
ga    Irish
gl    Galician
hu    Hungarian
he    Hebrew
hr    Croatian
is    Icelandic
it    Italian
ja    Japanese
ka    Georgian
ko    Korean
km    Khmer
kn    Kannada
lv    Latvian
mk    Macedonian
nl    Dutch
no    Norwegian
pl    Polish
pt    Portugese
pt-br Brazilian Portuguese
ro    Romanian
ru    Russian
sk    Slovak
sl    Slovenian
sr    Serbian
sv    Swedish
ta    Tamil
te    Telugu
tr    Turkish
uk    Ukrainian
zh-cn Simplified Chinese
zh-tw Traditional Chinese

Attachments (2)

i18n-doc-requestcontext-languages.diff (717 bytes) - added by Antti Kaihola 9 years ago.
correction to i18n.txt documentation
i18n-doc-requestcontext-languages.2.diff (853 bytes) - added by Antti Kaihola 8 years ago.
corrected correction to i18n documentation

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Antti Kaihola

correction to i18n.txt documentation

comment:1 Changed 8 years ago by Simon Greenhill

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 8 years ago by Marc Fargas

Resolution: worksforme
Status: newclosed

I just did a simple template to print LANGUAGES throught runserver and I got all language names translated to whatever language I set.
Your test case has something rare anyway.. Did you try that via runserver?

Closing as seems invalid unless you can reproduce it in a view (where requestcontext is supposed to be used).

comment:3 Changed 8 years ago by Antti Kaihola

I still insist that the documentation suggests the names of the languages should be in each language itself instead of the current active language, e.g.:

  • de Deutsch
  • en English
  • es español
  • fi Suomi
  • fr français
  • no norsk
  • sv svenska

I admit that I'm not a native English speaker, so I might have misunderstood the original sentence. In that case, other non-first-language English speakers might misunderstand it as well, and it would make sense to re-phrase.

My patch was of course wrong because it suggested that the language names are always in English. A fixed patch is on its way.

Changed 8 years ago by Antti Kaihola

corrected correction to i18n documentation

comment:4 Changed 8 years ago by Marc Fargas

Resolution: worksforme
Status: closedreopened

I misunderstood your description, indeed the documentation reads "Language names in the language of the language name" (more or less). So the real behaviour is not what is documented. Thanks for insisting.

comment:5 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: reopenedclosed

(In [7842]) Fixed #7061 -- Fixed a small inaccuracy in the i18n docs. Thanks akaihola.

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