Advertisement
Guest User

easy_lang_creator

a guest
Aug 26th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. import sys
  2.  
  3. def main():
  4.     script_path = ""
  5.     output_path = ""
  6.     if len(sys.argv) >= 2:
  7.         script_path = sys.argv[1]
  8.     else:
  9.         script_path = raw_input("Inserisci il percorso dello script: ")
  10.  
  11.     if len(sys.argv) >= 3:
  12.         output_path = sys.argv[2]
  13.     else:
  14.         output_path = raw_input("Inserisci il nome del file lang di output: ")
  15.  
  16.     o_script = open(script_path,"r")
  17.     w_lang = open(output_path,"w")
  18.     w_lang.write("// Generato con easy lang creator 1.0\n\n")
  19.     for line in o_script:
  20.         line = line.strip()
  21.         if line[0:1] != "#":
  22.             if (line.find('"') != -1 and line.find("'") == -1) or (line.find("'") != -1 and line.find('"') == -1):
  23.                 print "Linea:\t\t" + line
  24.                 split = line.split('"')
  25.                 for i in range(len(split)):
  26.                     if split[i] != "" and i%2 != 0:
  27.                         print 'Stringa:\t"' + split[i] + '"'
  28.                         mod = raw_input('Traduzione:\t')
  29.                         if mod != "-1":
  30.                             w_lang.write('_oldmsg = "'+split[i]+'"\n')
  31.                             w_lang.write('_newmsg = "'+mod+'"\n')
  32.                        
  33.                 print "" #un a capo
  34.                 w_lang.write("\n")
  35.  
  36.     o_script.close()
  37.     w_lang.close()
  38.     print "File .lang creato con successo"
  39.  
  40. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement