Django

Code

Show
Ignore:
Timestamp:
06/17/07 17:18:54 (2 years ago)
Author:
clong
Message:

per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/per-object-permissions/django/bin/compile-messages.py

    • Property svn:eol-style set to native
    r3732 r5488  
    11#!/usr/bin/env python 
    22 
     3import optparse 
    34import os 
    45import sys 
    56 
    6 def compile_messages(): 
     7def compile_messages(locale=None): 
    78    basedir = None 
    89 
     
    1415        print "This script should be run from the Django SVN tree or your project or app tree." 
    1516        sys.exit(1) 
     17 
     18    if locale is not None: 
     19        basedir = os.path.join(basedir, locale, 'LC_MESSAGES') 
    1620 
    1721    for dirpath, dirnames, filenames in os.walk(basedir): 
     
    2832                os.environ['djangocompilepo'] = pf + '.po' 
    2933                if sys.platform == 'win32': # Different shell-variable syntax 
    30                     cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"' 
     34                    cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"' 
    3135                else: 
    32                     cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"' 
     36                    cmd = 'msgfmt --check-format -o "$djangocompilemo" "$djangocompilepo"' 
    3337                os.system(cmd) 
    3438 
     39def main(): 
     40    parser = optparse.OptionParser() 
     41    parser.add_option('-l', '--locale', dest='locale', 
     42            help="The locale to process. Default is to process all.") 
     43    options, args = parser.parse_args() 
     44    if len(args): 
     45        parser.error("This program takes no arguments") 
     46    compile_messages(options.locale) 
     47 
    3548if __name__ == "__main__": 
    36     compile_messages() 
     49    main()