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
This commit is contained in:
Malcolm Tredinnick 2007-03-09 04:59:58 +00:00
parent 20a240cf51
commit fcd119bfb1
1 changed files with 15 additions and 2 deletions

View File

@ -1,9 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
import optparse
import os import os
import sys import sys
def compile_messages(): def compile_messages(locale=None):
basedir = None basedir = None
if os.path.isdir(os.path.join('conf', 'locale')): 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." print "This script should be run from the Django SVN tree or your project or app tree."
sys.exit(1) 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 dirpath, dirnames, filenames in os.walk(basedir):
for f in filenames: for f in filenames:
if f.endswith('.po'): if f.endswith('.po'):
@ -32,5 +36,14 @@ def compile_messages():
cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'
os.system(cmd) 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__": if __name__ == "__main__":
compile_messages() main()