110 return languageDict |
111 return languageDict |
111 |
112 |
112 |
113 |
113 def verbosePrint(verbose, str): |
114 def verbosePrint(verbose, str): |
114 if verbose: |
115 if verbose: |
115 print str |
116 print(str) |
116 |
117 |
117 |
118 |
118 def processCustomFiles(filein, fileout, regexp, prefix=''): |
119 def processCustomFiles(filein, fileout, regexp, prefix=''): |
119 appfil_file = open(filein, 'r') |
120 appfil_file = open(filein, 'r') |
120 messages_file = open(fileout, 'r') |
121 messages_file = open(fileout, 'r') |
298 os.chdir(currentDir) |
299 os.chdir(currentDir) |
299 |
300 |
300 |
301 |
301 def printUsage(errorMsg=None): |
302 def printUsage(errorMsg=None): |
302 """Displays how to use this script from the command line.""" |
303 """Displays how to use this script from the command line.""" |
303 print """ |
304 print(""" |
304 ################################################################################## |
305 ################################################################################## |
305 # mki18n : Make internationalization files. # |
306 # mki18n : Make internationalization files. # |
306 # Uses the GNU gettext system to create PO (Portable Object) files # |
307 # Uses the GNU gettext system to create PO (Portable Object) files # |
307 # from source code, coimpile PO into MO (Machine Object) files. # |
308 # from source code, coimpile PO into MO (Machine Object) files. # |
308 # Supports C,C++,Python source files. # |
309 # Supports C,C++,Python source files. # |
328 # # |
329 # # |
329 # You must specify one of the -p or -m option to perform the work. You can # |
330 # You must specify one of the -p or -m option to perform the work. You can # |
330 # specify the path of the target application. If you leave it out mki18n # |
331 # specify the path of the target application. If you leave it out mki18n # |
331 # will use the current directory as the application main directory. # |
332 # will use the current directory as the application main directory. # |
332 # # |
333 # # |
333 ##################################################################################""" |
334 ##################################################################################""") |
334 if errorMsg: |
335 if errorMsg: |
335 print "\n ERROR: %s" % errorMsg |
336 print("\n ERROR: %s" % errorMsg) |
336 |
337 |
337 |
338 |
338 def fileBaseOf(filename, withPath=0): |
339 def fileBaseOf(filename, withPath=0): |
339 """fileBaseOf(filename,withPath) ---> string |
340 """fileBaseOf(filename,withPath) ---> string |
340 |
341 |
471 sys.exit(0) |
472 sys.exit(0) |
472 option[optionKey[opt]] = 1 if val == '' else val |
473 option[optionKey[opt]] = 1 if val == '' else val |
473 if len(pargs) == 0: |
474 if len(pargs) == 0: |
474 appDirPath = os.getcwd() |
475 appDirPath = os.getcwd() |
475 if option['verbose']: |
476 if option['verbose']: |
476 print "No project directory given. Using current one: %s" % appDirPath |
477 print("No project directory given. Using current one: %s" % appDirPath) |
477 elif len(pargs) == 1: |
478 elif len(pargs) == 1: |
478 appDirPath = pargs[0] |
479 appDirPath = pargs[0] |
479 else: |
480 else: |
480 printUsage('Too many arguments (%u). Use double quotes if you have space in directory name' % len(pargs)) |
481 printUsage('Too many arguments (%u). Use double quotes if you have space in directory name' % len(pargs)) |
481 sys.exit(1) |
482 sys.exit(1) |
482 if option['domain'] is None: |
483 if option['domain'] is None: |
483 # If no domain specified, use the name of the target directory |
484 # If no domain specified, use the name of the target directory |
484 option['domain'] = fileBaseOf(appDirPath) |
485 option['domain'] = fileBaseOf(appDirPath) |
485 if option['verbose']: |
486 if option['verbose']: |
486 print "Application domain used is: '%s'" % option['domain'] |
487 print("Application domain used is: '%s'" % option['domain']) |
487 if option['po']: |
488 if option['po']: |
488 try: |
489 try: |
489 makePO(appDirPath, option['domain'], option['verbose']) |
490 makePO(appDirPath, option['domain'], option['verbose']) |
490 except IOError, e: |
491 except IOError, e: |
491 printUsage(e[1] + '\n You must write a file app.fil that contains the list of all files to parse.') |
492 printUsage(e[1] + '\n You must write a file app.fil that contains the list of all files to parse.') |