diff options
Diffstat (limited to 'django/bin/compile-messages.py')
| -rwxr-xr-x | django/bin/compile-messages.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/django/bin/compile-messages.py b/django/bin/compile-messages.py index 0137ec8dd4..2e1e908bbf 100755 --- a/django/bin/compile-messages.py +++ b/django/bin/compile-messages.py @@ -1,9 +1,10 @@ #!/usr/bin/env python +import optparse import os import sys -def compile_messages(): +def compile_messages(locale=None): basedir = None if os.path.isdir(os.path.join('conf', 'locale')): @@ -14,6 +15,9 @@ def compile_messages(): print "This script should be run from the Django SVN tree or your project or app tree." sys.exit(1) + if locale is not None: + basedir = os.path.join(basedir, locale, 'LC_MESSAGES') + for dirpath, dirnames, filenames in os.walk(basedir): for f in filenames: if f.endswith('.po'): @@ -27,10 +31,19 @@ def compile_messages(): os.environ['djangocompilemo'] = pf + '.mo' os.environ['djangocompilepo'] = pf + '.po' if sys.platform == 'win32': # Different shell-variable syntax - cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"' + cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"' else: - cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' + cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"' os.system(cmd) +def main(): + parser = optparse.OptionParser() + parser.add_option('-l', '--locale', dest='locale', + help="The locale to process. Default is to process all.") + options, args = parser.parse_args() + if len(args): + parser.error("This program takes no arguments") + compile_messages(options.locale) + if __name__ == "__main__": - compile_messages() + main() |
