Added contrib apps to ignore list when running makemessages in the Djagno source tree and added a --no-obsolete option in preparation of moving app translations out of core.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15258 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-01-21 17:30:35 +00:00
parent ccfd70c7ba
commit cf179e195d
1 changed files with 13 additions and 3 deletions

View File

@ -115,7 +115,8 @@ def copy_plural_forms(msgs, locale, domain, verbosity):
def make_messages(locale=None, domain='django', verbosity='1', all=False, def make_messages(locale=None, domain='django', verbosity='1', all=False,
extensions=None, symlinks=False, ignore_patterns=[], no_wrap=False): extensions=None, symlinks=False, ignore_patterns=[], no_wrap=False,
no_obsolete=False):
""" """
Uses the locale directory from the Django SVN tree or an application/ Uses the locale directory from the Django SVN tree or an application/
project to process all project to process all
@ -133,6 +134,8 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
if os.path.isdir(os.path.join('conf', 'locale')): if os.path.isdir(os.path.join('conf', 'locale')):
localedir = os.path.abspath(os.path.join('conf', 'locale')) localedir = os.path.abspath(os.path.join('conf', 'locale'))
invoked_for_django = True invoked_for_django = True
# Ignoring all contrib apps
ignore_patterns += ['contrib/*']
elif os.path.isdir('locale'): elif os.path.isdir('locale'):
localedir = os.path.abspath('locale') localedir = os.path.abspath('locale')
else: else:
@ -288,6 +291,11 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
finally: finally:
f.close() f.close()
os.unlink(potfile) os.unlink(potfile)
if no_obsolete:
msgs, errors = _popen('msgattrib %s -o "%s" --no-obsolete "%s"' %
(wrap, pofile, pofile))
if errors:
raise CommandError("errors happened while running msgattrib\n%s" % errors)
class Command(BaseCommand): class Command(BaseCommand):
@ -309,6 +317,8 @@ class Command(BaseCommand):
default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*' and '*~'."), default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*' and '*~'."),
make_option('--no-wrap', action='store_true', dest='no_wrap', make_option('--no-wrap', action='store_true', dest='no_wrap',
default=False, help="Don't break long message lines into several lines"), default=False, help="Don't break long message lines into several lines"),
make_option('--no-obsolete', action='store_true', dest='no_obsolete',
default=False, help="Remove obsolete message strings"),
) )
help = "Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory." help = "Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for project and application) directory."
@ -330,7 +340,7 @@ class Command(BaseCommand):
ignore_patterns += ['CVS', '.*', '*~'] ignore_patterns += ['CVS', '.*', '*~']
ignore_patterns = list(set(ignore_patterns)) ignore_patterns = list(set(ignore_patterns))
no_wrap = options.get('no_wrap') no_wrap = options.get('no_wrap')
no_obsolete = options.get('no_obsolete')
if domain == 'djangojs': if domain == 'djangojs':
extensions = handle_extensions(extensions or ['js']) extensions = handle_extensions(extensions or ['js'])
else: else:
@ -340,4 +350,4 @@ class Command(BaseCommand):
sys.stdout.write('examining files with the extensions: %s\n' sys.stdout.write('examining files with the extensions: %s\n'
% get_text_list(list(extensions), 'and')) % get_text_list(list(extensions), 'and'))
make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap) make_messages(locale, domain, verbosity, process_all, extensions, symlinks, ignore_patterns, no_wrap, no_obsolete)