*/}}

la_translation_gen.py 533 B

12345678910111213141516171819
  1. import sys,re
  2. if(len(sys.argv))<2:
  3. print("Provide a file!")
  4. exit(1)
  5. try:
  6. f=open(sys.argv[1])
  7. t=open("GeneratedTranslations.c",'w')
  8. lines = f.readlines()
  9. t.write("static const char *entries[]={\n")
  10. for l in lines:
  11. ma=re.search(r"(.*?)\s*\|\s*(.*)",l)
  12. if ma:
  13. t.write("\"%s\",\"%s\",\n"%(ma.group(1),ma.group(2)))
  14. t.write("0,0};\nfor(int i=0;;i++){if(!entries[i*2])break;\ntransNewEntry(entries[i*2],entries[i*2+1]);\n}")
  15. except:
  16. print("Error parsing file")
  17. exit(1)