# # This file is an aid to generate the Languages rules file. # usage: # python languages.py > ..\winbuild\Languages.rules # import os import re files = [f for f in os.listdir('.') if re.match(r'translator_[a-z][a-z]\.h', f)] new_list = [] for f in files: new_list.append([f,(os.path.splitext(f)[0]).replace("translator_","").upper()]) # # generating file is lang_cfg.py # the rules file has to output lang_cfg.h # print("""\ """) # # generate loop, English is mandatory (so cannot be chosen) # for f in new_list: if (f[1] != "EN"): # search for the language description fil = open(f[0], 'r') tmp = "" for line in fil: if "idLanguage" in line: tmp = line if "}" in line: break elif (tmp != ""): tmp += line if "}" in line: break tmp = tmp.replace("\n","") l = re.sub('[^"]*"([^"]*)".*','\\1',tmp) l1 = l.replace("-","") # capitalize first letter l = l.title() print("""\ """ % (l1, l, l, l, f[1], l)) print("""\ """)