Code

Opened 6 years ago

Closed 6 years ago

#7061 closed (fixed)

i18n docs contradict actual RequestContext behavior

Reported by: akaihola 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:

Description

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:

#!/usr/bin/python
from django.conf import settings
settings.configure()
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 akaihola 6 years ago.
correction to i18n.txt documentation
i18n-doc-requestcontext-languages.2.diff (853 bytes) - added by akaihola 6 years ago.
corrected correction to i18n documentation

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by akaihola

correction to i18n.txt documentation

comment:1 Changed 6 years ago by Simon Greenhill

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 6 years ago by telenieko

  • Resolution set to worksforme
  • Status changed from new to closed

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 6 years ago by akaihola

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 6 years ago by akaihola

corrected correction to i18n documentation

comment:4 Changed 6 years ago by telenieko

  • Resolution worksforme deleted
  • Status changed from closed to reopened

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 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.