Opened 13 years ago

Closed 13 years ago

#16764 closed Bug (needsinfo)

LANGUAGES and LANGUAGE_CODE settings doesn't work correctly

Reported by: anonymous Owned by: gaba
Component: Internationalization Version: 1.3
Severity: Normal Keywords: language settings
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Aymeric Augustin)

LANGUAGE_CODE = 'mn'

gettext = lambda s: s
LANGUAGES = (
    ('mn', gettext('Mongolia')),
    ('en-us', gettext('English')),
)

when above settings configured default language code is "mn", but

LANGUAGE_CODE = 'mn'

gettext = lambda s: s
LANGUAGES = (
    ('mn', gettext('Mongolia')),
    ('en', gettext('English')),
)

in this situation default language code is "en".

I added locale middleware to MIDDLEWARES.

It is BUG? or something?

Change History (5)

comment:1 by Aymeric Augustin, 13 years ago

Description: modified (diff)

Fixed formatting.

comment:2 by anonymous, 13 years ago

Owner: changed from nobody to gaba

comment:3 by gabelula@…, 13 years ago

Resolution: fixed
Status: newclosed
Triage Stage: UnreviewedAccepted

If you use the locale middleware did you check if your browser is not set up for english version or you have a cookie setup?
Check this:

"LocaleMiddleware tries to determine the user’s language preference by following this algorithm:

First, it looks for a django_language key in the current user’s session.
Failing that, it looks for a cookie.
Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
Failing that, it uses the global LANGUAGE_CODE setting."

on http://www.djangobook.com/en/2.0/chapter19/

en_US does not have a language translation in django so is not gonna be used in your application. Adding en_US to the languages is the same as not adding anything. As you can see if you only have 'mn' in your languages then it will only get the mongolian version of the site. If you have your browser setup to mongolian and you have en and mn in the languages then the site will be in mongolian.

Please, let me know if this resolves the issue.

in reply to:  3 comment:4 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: closedreopened
Triage Stage: AcceptedUnreviewed

Replying to gabelula@…:

en_US does not have a language translation in django so is not gonna be used in your application. Adding en_US to the languages is the same as not adding anything. As you can see if you only have 'mn' in your languages then it will only get the mongolian version of the site. If you have your browser setup to mongolian and you have en and mn in the languages then the site will be in mongolian.

Actually, that's not true, Django falls back to the base language (en) if the specific language (en-us) can't be found.

Also, please don't mark tickets as fixed if there wasn't a fix applied or solution found.

Responding to the ticket author: this needs more information of how to reproduce (I can't).

comment:5 by Carl Meyer, 13 years ago

Resolution: needsinfo
Status: reopenedclosed

I'm not able to reproduce this either - closing "needsinfo," please reopen if you can provide detailed instructions for how to reproduce the issue with trunk Django on a new project.

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