summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-01-21 17:30:35 +0000
committerJannis Leidel <jannis@leidel.info>2011-01-21 17:30:35 +0000
commitcf179e195d5525e0233385be97a53a6c5d7c6985 (patch)
tree7825fcd3fbb51778b7fc0c101d39591b0c531d9d
parentccfd70c7ba4852bdd849a714917165b5c5b77f30 (diff)
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
-rw-r--r--django/core/management/commands/makemessages.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index f02a3c8649..1b31164355 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -115,7 +115,8 @@ def copy_plural_forms(msgs, locale, domain, verbosity):
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/
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')):
localedir = os.path.abspath(os.path.join('conf', 'locale'))
invoked_for_django = True
+ # Ignoring all contrib apps
+ ignore_patterns += ['contrib/*']
elif os.path.isdir('locale'):
localedir = os.path.abspath('locale')
else:
@@ -288,6 +291,11 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False,
finally:
f.close()
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):
@@ -309,6 +317,8 @@ class Command(BaseCommand):
default=True, help="Don't ignore the common glob-style patterns 'CVS', '.*' and '*~'."),
make_option('--no-wrap', action='store_true', dest='no_wrap',
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."
@@ -330,7 +340,7 @@ class Command(BaseCommand):
ignore_patterns += ['CVS', '.*', '*~']
ignore_patterns = list(set(ignore_patterns))
no_wrap = options.get('no_wrap')
-
+ no_obsolete = options.get('no_obsolete')
if domain == 'djangojs':
extensions = handle_extensions(extensions or ['js'])
else:
@@ -340,4 +350,4 @@ class Command(BaseCommand):
sys.stdout.write('examining files with the extensions: %s\n'
% 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)