i18n/mki18n.py
changeset 2452 2f2b2152580f
parent 2441 c553769a65af
child 3750 f62625418bff
equal deleted inserted replaced
2451:6d1bf321fb89 2452:2f2b2152580f
    82 from __future__ import absolute_import
    82 from __future__ import absolute_import
    83 from __future__ import print_function
    83 from __future__ import print_function
    84 import os
    84 import os
    85 import sys
    85 import sys
    86 import re
    86 import re
       
    87 from builtins import str as text
    87 import wx
    88 import wx
       
    89 
    88 
    90 
    89 # -----------------------------------------------------------------------------
    91 # -----------------------------------------------------------------------------
    90 # Global variables
    92 # Global variables
    91 # ----------------
    93 # ----------------
    92 #
    94 #
   198         applicationName = applicationDomain
   200         applicationName = applicationDomain
   199     currentDir = os.getcwd()
   201     currentDir = os.getcwd()
   200     os.chdir(applicationDirectoryPath)
   202     os.chdir(applicationDirectoryPath)
   201     filelist = 'app.fil'
   203     filelist = 'app.fil'
   202     if not os.path.exists(filelist):
   204     if not os.path.exists(filelist):
   203         raise IOError(2, 'No module file: ' % filelist)
   205         raise IOError(2, 'No module file: %s' % filelist)
   204 
   206 
   205     fileout = 'messages.pot'
   207     fileout = 'messages.pot'
   206     # Steps:
   208     # Steps:
   207     #  Use xgettext to parse all application modules
   209     #  Use xgettext to parse all application modules
   208     #  The following switches are used:
   210     #  The following switches are used:
   485     }
   487     }
   486     exit_code = 1
   488     exit_code = 1
   487     try:
   489     try:
   488         optionList, pargs = getopt.getopt(sys.argv[1:], validOptions, validLongOptions)
   490         optionList, pargs = getopt.getopt(sys.argv[1:], validOptions, validLongOptions)
   489     except getopt.GetoptError as e:
   491     except getopt.GetoptError as e:
   490         printUsage(e[0])
   492         printUsage(e)
   491         sys.exit(1)
   493         sys.exit(1)
   492     for (opt, val) in optionList:
   494     for (opt, val) in optionList:
   493         if opt == '-h':
   495         if opt == '-h':
   494             printUsage()
   496             printUsage()
   495             sys.exit(0)
   497             sys.exit(0)
   511     if option['po']:
   513     if option['po']:
   512         try:
   514         try:
   513             makePO(appDirPath, option['domain'], option['verbose'])
   515             makePO(appDirPath, option['domain'], option['verbose'])
   514             exit_code = 0
   516             exit_code = 0
   515         except IOError as e:
   517         except IOError as e:
   516             printUsage(e[1] + '\n   You must write a file app.fil that contains the list of all files to parse.')
   518             printUsage(text(e) + '\n   You must write a file app.fil that contains the list of all files to parse.')
   517     if option['mo']:
   519     if option['mo']:
   518         makeMO(appDirPath, option['moTarget'], option['domain'], option['verbose'], option['forceEnglish'])
   520         makeMO(appDirPath, option['moTarget'], option['domain'], option['verbose'], option['forceEnglish'])
   519         exit_code = 0
   521         exit_code = 0
   520     sys.exit(exit_code)
   522     sys.exit(exit_code)
   521 
   523