Django

Code

Ticket #8702 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: hank Assigned to: mtredinnick
Milestone: 1.0 Component: django.contrib.admin
Version: SVN Keywords: admin i18n
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

prj.tar.gz (6.8 kB) - added by hankhu2001@gmail.com on 08/30/08 07:06:48.
My test project. Execute run.bat and open http://localhost:8080/admin, user/pass='hank'/'123'
setlang.diff (0.5 kB) - added by kmtracey on 08/30/08 13:45:36.
Patch, in case it's of use to anyone

Change History

08/29/08 21:59:35 changed by mtredinnick

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to worksforme.
  • needs_tests changed.
  • needs_docs changed.

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.

08/30/08 07:06:48 changed by hankhu2001@gmail.com

  • attachment prj.tar.gz added.

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

08/30/08 07:08:14 changed by hankhu2001@gmail.com

  • status changed from closed to reopened.
  • version changed from 0.96 to SVN.
  • resolution deleted.

08/30/08 11:55:21 changed by mtredinnick

  • status changed from reopened to closed.
  • resolution set to invalid.

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.

08/30/08 13:15:08 changed by arien

  • status changed from closed to reopened.
  • resolution deleted.

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.

08/30/08 13:41:01 changed 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'.)

08/30/08 13:45:36 changed by kmtracey

  • attachment setlang.diff added.

Patch, in case it's of use to anyone

08/30/08 13:51:21 changed by mtredinnick

  • owner changed from nobody to mtredinnick.
  • status changed from reopened to new.
  • stage changed from Unreviewed to Accepted.
  • milestone set to 1.0.

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.

08/30/08 15:17:59 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(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.

08/30/08 15:19:27 changed 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.


Add/Change #8702 (words not i18n-ized in admin interface when use '--noreload' option.)




Change Properties
Action