i18n/mki18n.py
changeset 814 5743cbdff669
parent 361 331d698e1118
child 1482 5d4543ee5a5d
equal deleted inserted replaced
813:1460273f40ed 814:5743cbdff669
   152     cmd = 'xgettext -s --no-wrap --language=Python --files-from=app.fil --output=messages.pot'
   152     cmd = 'xgettext -s --no-wrap --language=Python --files-from=app.fil --output=messages.pot'
   153     if verbose: print cmd
   153     if verbose: print cmd
   154     os.system(cmd)                                                
   154     os.system(cmd)                                                
   155 
   155 
   156     appfil_file = open("app.fil", 'r')
   156     appfil_file = open("app.fil", 'r')
       
   157     messages_file = open("messages.pot", 'r')
       
   158     messages = messages_file.read()
       
   159     messages_file.close()
   157     messages_file = open("messages.pot", 'a')
   160     messages_file = open("messages.pot", 'a')
   158     messages_file.write("""
   161     messages_file.write("""
   159 #: Extra XSD strings
   162 #: Extra XSD strings
   160 """)
   163 """)
   161     words_found = {}
   164     words_found = {}
   162     for filepath in appfil_file.xreadlines():
   165     for filepath in appfil_file.xreadlines():
   163         code_file = open(filepath.strip(), 'r')
   166         code_file = open(filepath.strip(), 'r')
   164         for match in XSD_STRING_MODEL.finditer(code_file.read()):
   167         for match in XSD_STRING_MODEL.finditer(code_file.read()):
   165 				    word = match.group(1)
   168             word = match.group(1)
   166 				    if not words_found.get(word, False):
   169             if not words_found.get(word, False) and messages.find("msgid \"%s\"\nmsgstr \"\"" % word) == -1:
   167 				        words_found[word] = True
   170                 words_found[word] = True
   168 				        messages_file.write("""
   171                 messages_file.write("""
   169 msgid "%s"
   172 msgid "%s"
   170 msgstr ""
   173 msgstr ""
   171 """%word)
   174 """%word)
   172         code_file.close()
   175         code_file.close()
   173     messages_file.close()
   176     messages_file.close()