Aljosa Mohorovic
unread,Dec 1, 2008, 7:00:44 PM12/1/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
i usually use svn:externals to add django, extensions, evolution and
other stuff to my projects but when i use makemessages in this
situation it generates locale for everything in current folder.
i've added some code to makemessages to enable excluding folders by
pattern to resolve my current situation:
$ django-admin makemessages -l hr --exclude_regex="^\.\/(django|
photologue)"
i'm sure that there is a better way (since this introduces problems
when i update django), any tips?
Aljosa Mohorovic
svn diff:
Index: core/management/commands/makemessages.py
===================================================================
--- core/management/commands/makemessages.py (revision 9538)
+++ core/management/commands/makemessages.py (working copy)
@@ -43,7 +43,7 @@
# trick xgettext to parse them as Python files)
return set([x for x in ext_list if x != '.py'])
-def make_messages(locale=None, domain='django', verbosity='1',
all=False, extensions=None):
+def make_messages(locale=None, domain='django', verbosity='1',
all=False, extensions=None, exclude_regex=None):
"""
Uses the locale directory from the Django SVN tree or an
application/
project to process all
@@ -114,7 +114,15 @@
for (dirpath, dirnames, filenames) in os.walk("."):
all_files.extend([(dirpath, f) for f in filenames])
all_files.sort()
+
+ if exclude_regex != None:
+ exclude_pattern = re.compile(exclude_regex)
for dirpath, file in all_files:
+ if exclude_regex != None:
+ if exclude_pattern.match(dirpath) != None:
+ print 'Excluding folder: ', dirpath
+ continue
+
file_base, file_ext = os.path.splitext(file)
if domain == 'djangojs' and file_ext == '.js':
if verbosity > 1:
@@ -199,6 +207,7 @@
make_option('--verbosity', '-v', action='store',
dest='verbosity',
default='1', type='choice', choices=['0', '1', '2'],
help='Verbosity level; 0=minimal output, 1=normal output,
2=all output'),
+ make_option('--exclude_regex', default=None, help='To exclude
folder(s) provide regex.'),
make_option('--all', '-a', action='store_true', dest='all',
default=False, help='Reexamines all source code and
templates for new translation strings and updates all message files
for all available languages.'),
make_option('--extension', '-e', dest='extensions',
@@ -219,6 +228,7 @@
verbosity = int(options.get('verbosity'))
process_all = options.get('all')
extensions = options.get('extensions') or ['html']
+ exclude_regex = options.get('exclude_regex')
if domain == 'djangojs':
extensions = []
@@ -228,4 +238,4 @@
if '.js' in extensions:
raise CommandError("JavaScript files should be examined
by using the special 'djangojs' domain only.")
- make_messages(locale, domain, verbosity, process_all,
extensions)
+ make_messages(locale, domain, verbosity, process_all,
extensions, exclude_regex)