Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8702 closed (fixed)

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

Reported by: hank Owned by: mtredinnick
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@… 7 years ago.
My test project. Execute run.bat and open http://localhost:8080/admin, user/pass='hank'/'123'
setlang.diff (550 bytes) - added by kmtracey 7 years ago.
Patch, in case it's of use to anyone

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 7 years ago by hankhu2001@…

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

comment:2 Changed 7 years ago by hankhu2001@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 0.96 to SVN

comment:3 Changed 7 years ago by mtredinnick

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

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 7 years ago by arien

  • Resolution invalid deleted
  • Status changed from closed to reopened

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 7 years ago by kmtracey

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 7 years ago by kmtracey

Patch, in case it's of use to anyone

comment:6 Changed 7 years ago by mtredinnick

  • milestone set to 1.0
  • Owner changed from nobody to mtredinnick
  • Status changed from reopened to new
  • Triage Stage changed from Unreviewed to Accepted

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

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

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

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 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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