#18533: makemessages command fails on windows
--------------------------------------------+--------------------
     Reporter:  pasha.savchenko@…           |      Owner:  nobody
         Type:  Bug                         |     Status:  new
    Component:  Core (Management commands)  |    Version:  1.4
     Severity:  Normal                      |   Keywords:
 Triage Stage:  Unreviewed                  |  Has patch:  0
Easy pickings:  0                           |      UI/UX:  0
--------------------------------------------+--------------------
 Following the direction for i18n using gettext, I've installed gettext
 (tried 0.17 and 0.18.X) on several Windows machines and always fail with
 the same error:


 {{{
 CommandError: errors happened while running xgettext on __init__.py
 xgettext: error while opening ".\__init__.py" for reading: No such file or
 directory
 }}}

 The most obvious suspect is a bad relative path, so I've traced the
 problem to this area (lines 189-204) in
 core/management/commands/makemessage.py:
 {{{
             content = templatize(src_data, orig_file[2:])
             f = open(os.path.join(dirpath, thefile), "w")
             try:
                 f.write(content)
             finally:
                 f.close()
         work_file = os.path.join(dirpath, thefile)
         cmd = (
             'xgettext -d %s -L Python %s %s --keyword=gettext_noop '
             '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 '
             '--keyword=ugettext_noop --keyword=ugettext_lazy '
             '--keyword=ungettext_lazy:1,2 --keyword=pgettext:1c,2 '
             '--keyword=npgettext:1c,2,3 --keyword=pgettext_lazy:1c,2 '
             '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 '
             '--add-comments=Translators -o - "%s"' %
             (domain, wrap, location, work_file))
 }}}

 The fix was simple, replacing {{{work_file = os.path.join(dirpath,
 thefile)}}} with {{{work_file = os.path.abspath(os.path.join(dirpath,
 thefile))}}} solved the issue.

 Please look into making all paths absolute in management commands
 (especially ones that run external utils). Attached my fixed
 makemessages.py file.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18533>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to