﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18533	makemessages command fails on windows	pasha.savchenko@…	nobody	"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."	Bug	closed	Core (Management commands)	1.4	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
