diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-03-09 04:59:58 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-03-09 04:59:58 +0000 |
| commit | fcd119bfb18b20e81457f845b826733eee9c0cd0 (patch) | |
| tree | ab8d6435ce2a3da6b4fdee0347de28c0f733748d | |
| parent | 20a240cf5137cf3ca1468b55ef44aeef47a50312 (diff) | |
Fixed #3679 -- Added an option to compile localisation messages for a single
locale.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4687 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rwxr-xr-x | django/bin/compile-messages.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/django/bin/compile-messages.py b/django/bin/compile-messages.py index 0137ec8dd4..f2193d3122 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'): @@ -32,5 +36,14 @@ def compile_messages(): cmd = 'msgfmt -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() |
