Ticket #16903: no-location.patch
File no-location.patch, 5.3 KB (added by , 13 years ago) |
---|
-
django/core/management/commands/makemessages.py
116 116 117 117 def make_messages(locale=None, domain='django', verbosity='1', all=False, 118 118 extensions=None, symlinks=False, ignore_patterns=[], no_wrap=False, 119 no_location=False, 119 120 no_obsolete=False): 120 121 """ 121 122 Uses the locale directory from the Django SVN tree or an application/ … … 164 165 languages = [os.path.basename(l) for l in locale_dirs] 165 166 166 167 wrap = no_wrap and '--no-wrap' or '' 168 location = no_location and '--no-location' or '' 167 169 168 170 for locale in languages: 169 171 if verbosity > 0: … … 192 194 finally: 193 195 f.close() 194 196 cmd = ( 195 'xgettext -d %s -L C %s --keyword=gettext_noop '197 'xgettext -d %s -L C %s %s --keyword=gettext_noop ' 196 198 '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 ' 197 199 '--keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 ' 198 200 '--from-code UTF-8 --add-comments=Translators -o - "%s"' % ( 199 domain, wrap, os.path.join(dirpath, thefile)201 domain, wrap, location, os.path.join(dirpath, thefile) 200 202 ) 201 203 ) 202 204 msgs, errors = _popen(cmd) … … 236 238 if verbosity > 1: 237 239 sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 238 240 cmd = ( 239 'xgettext -d %s -L Python %s --keyword=gettext_noop '241 'xgettext -d %s -L Python %s %s --keyword=gettext_noop ' 240 242 '--keyword=gettext_lazy --keyword=ngettext_lazy:1,2 ' 241 243 '--keyword=ugettext_noop --keyword=ugettext_lazy ' 242 244 '--keyword=ungettext_lazy:1,2 --keyword=pgettext:1c,2 ' 243 245 '--keyword=npgettext:1c,2,3 --keyword=pgettext_lazy:1c,2 ' 244 246 '--keyword=npgettext_lazy:1c,2,3 --from-code UTF-8 ' 245 247 '--add-comments=Translators -o - "%s"' % ( 246 domain, wrap, os.path.join(dirpath, thefile))248 domain, wrap, location, os.path.join(dirpath, thefile)) 247 249 ) 248 250 msgs, errors = _popen(cmd) 249 251 if errors: … … 273 275 os.unlink(os.path.join(dirpath, thefile)) 274 276 275 277 if os.path.exists(potfile): 276 msgs, errors = _popen('msguniq %s --to-code=utf-8 "%s"' %277 (wrap, potfile))278 msgs, errors = _popen('msguniq %s %s --to-code=utf-8 "%s"' % 279 (wrap, location, potfile)) 278 280 if errors: 279 281 os.unlink(potfile) 280 282 raise CommandError( … … 285 287 f.write(msgs) 286 288 finally: 287 289 f.close() 288 msgs, errors = _popen('msgmerge %s -q "%s" "%s"' %289 (wrap, pofile, potfile))290 msgs, errors = _popen('msgmerge %s %s -q "%s" "%s"' % 291 (wrap, location, pofile, potfile)) 290 292 if errors: 291 293 os.unlink(potfile) 292 294 raise CommandError( … … 302 304 f.close() 303 305 os.unlink(potfile) 304 306 if no_obsolete: 305 msgs, errors = _popen('msgattrib %s -o "%s" --no-obsolete "%s"' %306 (wrap, pofile, pofile))307 msgs, errors = _popen('msgattrib %s %s -o "%s" --no-obsolete "%s"' % 308 (wrap, location, pofile, pofile)) 307 309 if errors: 308 310 raise CommandError( 309 311 "errors happened while running msgattrib\n%s" % errors) … … 328 330 default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*' and '*~'."), 329 331 make_option('--no-wrap', action='store_true', dest='no_wrap', 330 332 default=False, help="Don't break long message lines into several lines"), 333 make_option('--no-location', action='store_true', dest='no_location', 334 default=False, help="Don't write '#: filename:line' lines"), 331 335 make_option('--no-obsolete', action='store_true', dest='no_obsolete', 332 336 default=False, help="Remove obsolete message strings"), 333 337 ) … … 352 356 ignore_patterns += ['CVS', '.*', '*~'] 353 357 ignore_patterns = list(set(ignore_patterns)) 354 358 no_wrap = options.get('no_wrap') 359 no_location = options.get('no_location') 355 360 no_obsolete = options.get('no_obsolete') 356 361 if domain == 'djangojs': 357 362 extensions = handle_extensions(extensions or ['js']) … … 362 367 sys.stdout.write('examining files with the extensions: %s\n' 363 368 % get_text_list(list(extensions), 'and')) 364 369 365 make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_ obsolete)370 make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_location, no_obsolete)