--
Ticket URL: <https://code.djangoproject.com/ticket/17379>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* type: Uncategorized => Bug
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:1>
Comment (by chrischambers):
See also: https://code.djangoproject.com/ticket/11648, which might require
the same fix (albeit for a different reason) if the underlying issue
isn't/can't be corrected (https://code.djangoproject.com/ticket/9340).
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:2>
* needs_docs: 0 => 1
* has_patch: 0 => 1
* version: 1.3 => SVN
* stage: Unreviewed => Accepted
Comment:
Attached patch with a possible approach to the problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:3>
Comment (by lpiatek):
Comment on
https://code.djangoproject.com/attachment/ticket/17379/17379-1.diff patch:
- keep_active_language is not required, can_import_settings is only used
for what we want to turn off. So maybe we do not need new flag?
- printing sholdn't be done on stderr, but on stdout?
- we changed information to: "Active language set to 'en-us'.\n"
Comment on whole:
- there should be in BaseCommand Class functions like: _pre_execute(self),
_post_execute(self) when such things like translations would be run, but
this kind of change requires 'Design Decision', so we ommit it for now
#djangosprint-krakow
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:4>
* needs_better_patch: 0 => 1
Comment:
Totally agree about changes related to stderr/stdout.
However I don't see how {{{can_import_settings}}} and
{{{keep_active_language}}} are related. For me, those are two different
unrelated flags, or am I missing something?
{{{
``can_import_settings``
A boolean indicating whether the command needs to be able to
import Django settings; if ``True``, ``execute()`` will verify
that this is possible before proceeding. Default value is
``True``.
}}}
In some cases, we probably will have commands with {{{can_import_settings
= True}}}, but where we don't want to switch to en-us.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:5>
Comment (by ramiro):
I'd like to ask to the contributors working on this ticket what are the
practical consequences (as in concrete use cases) for the 'shell'and
'makemessages' of being run always with the en-us locale.
It is not clear to me why both of them are particular among the rest of
the commands and IMHO having that information would be helpful when it
comes to solve/re-triage this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:6>
Comment (by neaf):
The ticket requested shell to respect locale setting. Since it's an
interface to your app there's no reason not to do that. You might want to
see how your locale or other functionality that depends on i18n behaves.
can_import_settings was supposed to check if settings are available before
execution of a command according to documentation
(https://docs.djangoproject.com/en/dev/howto/custom-management-
commands/#BaseCommand.can_import_settings). It was doing that only by
coincidence… it was doing that by forcing en_us locale via translation
module which relies on settings.
makemessages used that coincidental behavior to avoid forced locale and
respect language set in your settings file.
The patch decouples can_import_settings from the locale forcing behavior
to allow its proper usage as described in documentation.
makemessages implementation didn't change. The only difference is it now
uses force_en_us_locale instead of can_import_settings to achieve the same
thing.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:7>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:8>
* needs_better_patch: 0 => 1
Comment:
Thanks for the explanation.
I'd like to:
* Review if raising `StandardError` when force_en_us_locale = True and
can_import_settings = False is the right thing to do
* Decide if compilemessages (the only other one command that sets
can_import_settings = False) does that because it needs to load settings
or as a side effect of needind to activate locale, just as makemessages
did
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:9>
* cc: lpiatek (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:10>
* cc: neaf (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:11>
Comment (by lpiatek):
Raising StandardError when force_en_us_locale = True and
can_import_settings = False:
- for me it's wrong cause force_en_us_locale according to patch is set to
True by default, so any command which now has can_import_settings = False
would throw mentioned Exception. We just can't assume we need
Possible options:
- set force_en_us_locale to False by default, and enable it where
necessary (?), don't really know where and for what it is used (is it
really necessary), we only have commen:
{{{
# Switch to English, because django-admin.py creates database
content
# like permissions, and those shouldn't contain any translations.
# But only do this if we can assume we have a working settings
file,
# because django.utils.translation requires settings.
}}}
- don't see any other/better better
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:12>
* status: new => assigned
* owner: nobody => ramiro
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:13>
Comment (by ramiro):
I've opened #19730 to track the unfolding of the meaning of the
`can_import_settings` option.
I'm also changing the title of this one from "Silent translation of all
./manage.py commands to en-us unexpected/undocumented" "Don't force output
of the 'shell' management command to en-us" because the fact that by
default commands use the en_US locale isn't undocumented (see "Management
commands and locales" note in https://docs.djangoproject.com/en/1.4/howto
/custom-management-commands/) and hence it shouldn't be unexpected.
Let's discuss in this ticket if it's possible to the 'shell' command to
use the locale configured by the developer for the project if USE_I18N is
active.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:14>
Comment (by ramiro):
#19737 proposes deprecating the shell command. If accepted, that would
turn this ticket irrelevant.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:15>
Comment (by claudep):
I really think that this isn't about the shell command only. We should
only switch to a specific locale when it is required by the command. I
worked on a branch (proof of concept, unfinished) demonstrating this here:
https://github.com/claudep/django/compare/simplify_commands
I'm not totally convinced about the decorator pattern used, but you get
the idea.
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:16>
* easy: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:17>
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:18>
* needs_better_patch: 1 => 0
* needs_docs: 1 => 0
Comment:
I updated my branch and made it a
[https://github.com/django/django/pull/8627 PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:19>
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:20>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:21>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:22>
* type: Bug => Cleanup/optimization
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:23>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d65b0f72de8d35617fe0554ddabc950c7f323eef" d65b0f7]:
{{{
#!CommitTicketReference repository=""
revision="d65b0f72de8d35617fe0554ddabc950c7f323eef"
Fixed #17379 -- Removed management commands deactivation of the locale.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/17379#comment:24>