Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#8702 closed (fixed)

words not i18n-ized in admin interface when use '--noreload' option.

Reported by: hank Owned by: Malcolm Tredinnick
Component: contrib.admin Version: master
Severity: Keywords: admin i18n
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I use development server and start it with '--noreload' option. When I enter admin page, all words but strings in my models.py are not i18n-ized.
I18n is ok without '--noreload' option.

Attachments (2)

prj.tar.gz (6.8 KB) - added by hankhu2001@… 8 years ago.
My test project. Execute run.bat and open http://localhost:8080/admin, user/pass='hank'/'123'
setlang.diff (550 bytes) - added by Karen Tracey 8 years ago.
Patch, in case it's of use to anyone

Download all attachments as: .zip

Change History (11)

comment:1 Changed 8 years ago by Malcolm Tredinnick

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: worksforme
Status: newclosed

Seems to work fine on trunk. We've fixed a few loading problems with the translation stuff in between 0.96 and now, so there's a reasonable chance it has been fixed in the interim.

Changed 8 years ago by hankhu2001@…

Attachment: prj.tar.gz added

My test project. Execute run.bat and open http://localhost:8080/admin, user/pass='hank'/'123'

comment:2 Changed 8 years ago by hankhu2001@…

Resolution: worksforme
Status: closedreopened
Version: 0.96SVN

comment:3 Changed 8 years ago by Malcolm Tredinnick

Resolution: invalid
Status: reopenedclosed

You don't have the LocaleMiddleware installed in your settings, so the internationalization infrastructure isn't enabled. When I include that middleware, it works fine. If you're still having problems with this, please ask on the django-users mailing list. This really isn't a bug in Django.

comment:4 Changed 8 years ago by arien

Resolution: invalid
Status: closedreopened

The bug is this one: the settings file has LANGUAGE_CODE = 'zh-cn' so the admin site should be displayed in Simplified Chinese, but it isn't when the --noreload option is used.

comment:5 Changed 8 years ago by Karen Tracey

It's because of the translation.activate('en-us') done in django/core/management/base.py's execute(). A way to fix it is to put:

            from django.conf import settings
            from django.utils import translation
            translation.activate(settings.LANGUAGE_CODE)

before the call to inner_run() on the else leg of if use_reloader in django/core/management/commands/runserver.py's handle() method. Sort of an edge case, but it does explain to me why setting LANGUAGE_CODE in settings.py never worked when running under a debugger that needed --noreload.

(A better way might be to only do the English activation when really necessary, but I don't know what set of things to check for to determine 'really necessary'.)

Changed 8 years ago by Karen Tracey

Attachment: setlang.diff added

Patch, in case it's of use to anyone

comment:6 Changed 8 years ago by Malcolm Tredinnick

milestone: 1.0
Owner: changed from nobody to Malcolm Tredinnick
Status: reopenednew
Triage Stage: UnreviewedAccepted

Okay, sorry to all for the confusion on my part. Arien smacked me around on IRC and got me to see what the real issue was. This fix looks sufficiently isolated that we can consider it for 1.0.

comment:7 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [8749]) Fixed #8702 -- Set up the initial locale correctly for the development server.
Previously, "--noreload" wasn't picking up the default language setting. Thanks
to arien and Karen Tracey for debugging this.

comment:8 Changed 8 years ago by Malcolm Tredinnick

I ended up putting the activate() call inside run_inner() because it seems almost accidental that it works in the autoreload case and I didn't want that to strangely stop working at some point in the future.

comment:9 Changed 5 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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