4 ## This is web_post.py. This script deals with translations
5 ## in the "make website" target.
17 #indir, outdir = sys.argv[1:]
19 # FIXME: looks dangerous!
23 html_files = glob.glob( os.path.join(indir, '*.html') )
25 # messy way to get all languages
27 for file in html_files:
28 file_split = file.split('.')
29 if (len(file_split) == 2):
36 langs = list(langs_set)
39 def makeFooter(currentLang):
40 text = "<p id=\"languages\">\n"
41 text += "Other languages: "
42 for i in range(len(langs)):
44 if (l == currentLang):
46 text += "<a href=\"index"
50 text += lang_lookup[l]
52 if (i < len(langs)-2):
56 # TODO: add link to automatic language selection?
57 # still need to include this page in the new webpages somewhere
62 for file in html_files:
63 file_split = file.split('.')
64 # we want to strip the .html
65 out_filename = os.path.basename(file_split[0])
66 if (len(file_split) == 2):
72 out_filename += '.'+lang
74 # I can't get the previous name to work
75 out_filename = os.path.basename(file)
77 # translation links should point to translations
78 lines = open(file).readlines()
82 lang_footer = makeFooter(lang)
84 outfile = open( os.path.join(outdir, out_filename), 'w')
86 # avoid external links
87 if ((line.find("href") >= 0) and (line.find("http")==-1)):
88 # eventually we want to do this, but I can't get it to work.
89 # waiting for help with apache (?)
90 # line = line.replace(".html", "."+lang)
95 line = line.replace(".html", text)
96 if (line.find("<!-- FOOTER -->") >= 0):
97 outfile.write( lang_footer )