Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20058 closed Cleanup/optimization (fixed)

compilemessages outputs to stderr

Reported by: d4n1h4ck@… Owned by: nobody
Component: Internationalization Version: 1.5
Severity: Normal Keywords: compilemessage Fail
Cc: bmispelon@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When trying to compile translations in Django 1.5, "python .. / manage.py compilemessages" has the following output (in red):
django.po processing file in / home / ... / env / project / locale / en_US / LC_MESSAGES

Have you tried the same procedure with versions less than or equal to 1.4 and everything works normally. This failure only occurs in Django 1.5.

The string is generated and usually marked

Environment used: Debian Sid with Gnome3 with python-dev, gettext installed and other libraries.

Environment virtualenv:
Django == 1.5
Pillow == 1.7.8
SQLite3Database == 0.2.0
Unipath == 0.2.1
argparse == 1.2.1
distribute == 0.6.31
psycopg2 == 2.4.6
unittest2 == 0.5.1
wsgiref == 0.1.2

Change History (12)

comment:1 by Claude Paroz, 11 years ago

Component: TranslationsInternationalization

It is not very clear for me what the problem exactly is. Could you give us the full output of a failing command?

comment:2 by d4n1, 11 years ago

Simply the output of the command "python manage.py compilemessages" is the line in red, no other Menssagens error:
django.po processing file in /home/dani/Development/env/project/locale/en_US/LC_MESSAGES

That is the command fails, but generates the file .mo but the translation does not work.

The locale folder are in my root project.

comment:3 by Baptiste Mispelon, 11 years ago

Cc: bmispelon@… added
Has patch: set
Summary: compilemessages failcompilemessages outputs to stderr
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Hello,

The issue here is that compilemessages writes its output to stderr, making it look like an error happens when in fact the command was successful (as proven by the fact that a .mo file is generated).

I don't see any reason why stderr was used in the first place other than the fact that it's always been this way (I tracked the issue to the introduction of the command itself with commit 5cf8f684237ab5addaf3549b2347c3adf107c0a7). The makemessages command itself uses sys.stdout.

The fact that your translations are not working is a different issue, probably caused by a mis-configuration.

I made a PR to have compilemessages use sys.stdout instead of sys.stderr: https://github.com/django/django/pull/910

comment:4 by Baptiste Mispelon <bmispelon@…>, 11 years ago

Resolution: fixed
Status: newclosed

In d5683bd06bdac923f73954020c760a4adb496be8:

Fix #20058: Make compilemessages use stdout instead of stderr.

comment:5 by Claude Paroz <claude@…>, 11 years ago

In 74a80a5169a1c870e6c2f78a18f67b366b0f60de:

Merge pull request #910 from bmispelon/ticket-20058

Fix #20058: Make compilemessages use stdout instead of stderr.

comment:6 by d4n1, 11 years ago

I changed entries stderr to stdout in django/core/management/commands/compilemessages.py, and tried to build. The Feedback is now in normal color. But the translation does not work yet. The Admin is usually translated, but my templates, views and urls not.

I'm using the standard language and Portuguese of Brazil.

Thanks.

comment:7 by Claude Paroz, 11 years ago

You can check if django.mo files are generated beside the django.po template files. If they are, then the issue is not compilemessages. Then you might give us a sample project which we can use to reproduce the problem.

comment:8 by d4n1, 11 years ago

Any project I do with Django 1.5 gives the same result, compiles and generates the file .mo but the Internationalization doesn't work. I created a basic project based on "Polls" Sample and applied internationalization, to Portuguese, following the documentation Django 1.5 but doesn't work.

Do you have projects with Djago 1.5 with internationalization? Is it working?

comment:9 by d4n1, 11 years ago

Djangos,

If I create my locale directory in the root of the project does not work, but if I create the directory locale in my app it works.

Anyone know why?

comment:10 by d4n1, 11 years ago

I just need to create my locale in my app directory and not the root of the project.

If you want to configure the root just add the following in settings.py constant (using Unipath):

LOCALE_PATHS = (

PROJECT_DIR.child (locale)

)

Using the conventions of Django, "Convention over configuration", must set only STATIC_ROOT (for media, static, template and locale of the app will already be recognized by Django convention):

STATIC_ROOT = PROJECT_DIR.child ('public')

Thanks and sorry my false alert :D

comment:11 by Roman Kalinichenko, 11 years ago

Did your solution has worked. I can't get internalization on my custom template. Folder's template lay on project directory.
Do I need to add to LOCALE_PATHS for a project directory like? :
LOCALE_PATHS = (
PROJECT_DIR.child (locale)
)

Also if I switch to django 1.4 that it work prefect.

Thanks

comment:12 by Roman Kalinichenko, 11 years ago

For notice you I use django 1.5 on development version

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