diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 955a822..21d6d0b 100644
a
|
b
|
def handle_extensions(extensions=('html',)):
|
38 | 38 | # trick xgettext to parse them as Python files) |
39 | 39 | return set([x for x in ext_list if x != '.py']) |
40 | 40 | |
41 | | def _popen(cmd): |
| 41 | def _popen(cmd, cwd=None): |
42 | 42 | """ |
43 | 43 | Friendly wrapper around Popen for Windows |
44 | 44 | """ |
45 | | p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True) |
| 45 | p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True, cwd=cwd) |
46 | 46 | return p.communicate() |
47 | 47 | |
48 | 48 | def walk(root, topdown=True, onerror=None, followlinks=False): |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
133 | 133 | if os.path.isdir(os.path.join('conf', 'locale')): |
134 | 134 | localedir = os.path.abspath(os.path.join('conf', 'locale')) |
135 | 135 | invoked_for_django = True |
| 136 | relpath = os.path.join(os.path.pardir, os.path.dir) |
136 | 137 | elif os.path.isdir('locale'): |
137 | 138 | localedir = os.path.abspath('locale') |
| 139 | relpath = os.path.pardir |
138 | 140 | else: |
139 | 141 | raise CommandError("This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or application, maybe you are just missing the conf/locale (in the django tree) or locale (for project and application) directory? It is not created automatically, you have to create it by hand if you want to enable i18n for your project or application.") |
140 | 142 | |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
168 | 170 | if verbosity > 0: |
169 | 171 | print "processing language", locale |
170 | 172 | basedir = os.path.join(localedir, locale, 'LC_MESSAGES') |
| 173 | # relative path from the PO file to the root of the application/project |
| 174 | relpath = os.path.join(relpath, os.path.pardir, os.path.pardir) |
171 | 175 | if not os.path.isdir(basedir): |
172 | 176 | os.makedirs(basedir) |
173 | 177 | |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
190 | 194 | f.write(src) |
191 | 195 | finally: |
192 | 196 | f.close() |
193 | | cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile)) |
194 | | msgs, errors = _popen(cmd) |
| 197 | cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.normpath(os.path.join(relpath, dirpath, thefile))) |
| 198 | msgs, errors = _popen(cmd, cwd=basedir) |
195 | 199 | if errors: |
196 | 200 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
197 | | old = '#: '+os.path.join(dirpath, thefile)[2:] |
198 | | new = '#: '+os.path.join(dirpath, file)[2:] |
| 201 | old = '#: '+os.path.join(relpath, dirpath[2:], thefile) |
| 202 | new = '#: '+os.path.join(relpath, dirpath[2:], file) |
199 | 203 | msgs = msgs.replace(old, new) |
200 | 204 | if os.path.exists(potfile): |
201 | 205 | # Strip the header |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
226 | 230 | if verbosity > 1: |
227 | 231 | sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) |
228 | 232 | cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % ( |
229 | | domain, os.path.join(dirpath, thefile)) |
230 | | msgs, errors = _popen(cmd) |
| 233 | domain, os.path.normpath(os.path.join(relpath, dirpath, thefile))) |
| 234 | msgs, errors = _popen(cmd, cwd=basedir) |
231 | 235 | if errors: |
232 | 236 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
233 | 237 | |
234 | 238 | if thefile != file: |
235 | | old = '#: '+os.path.join(dirpath, thefile)[2:] |
236 | | new = '#: '+os.path.join(dirpath, file)[2:] |
| 239 | old = '#: '+os.path.join(relpath, dirpath[2:], thefile) |
| 240 | new = '#: '+os.path.join(relpath, dirpath[2:], file) |
237 | 241 | msgs = msgs.replace(old, new) |
238 | 242 | if os.path.exists(potfile): |
239 | 243 | # Strip the header |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
250 | 254 | os.unlink(os.path.join(dirpath, thefile)) |
251 | 255 | |
252 | 256 | if os.path.exists(potfile): |
253 | | msgs, errors = _popen('msguniq --to-code=utf-8 "%s"' % potfile) |
| 257 | msgs, errors = _popen('msguniq --to-code=utf-8 "%s"' % potfile, cwd=basedir) |
254 | 258 | if errors: |
255 | 259 | raise CommandError("errors happened while running msguniq\n%s" % errors) |
256 | 260 | f = open(potfile, 'w') |
… |
… |
def make_messages(locale=None, domain='django', verbosity='1', all=False,
|
259 | 263 | finally: |
260 | 264 | f.close() |
261 | 265 | if os.path.exists(pofile): |
262 | | msgs, errors = _popen('msgmerge -q "%s" "%s"' % (pofile, potfile)) |
| 266 | msgs, errors = _popen('msgmerge -q "%s" "%s"' % (pofile, potfile), cwd=basedir) |
263 | 267 | if errors: |
264 | 268 | raise CommandError("errors happened while running msgmerge\n%s" % errors) |
265 | 269 | elif not invoked_for_django: |