4 ## This is web_post.py. This script deals with translations
5 ## in the "make website" target.
19 'es': 'Blargle flop: ',
20 'fr': 'lirer des autres langs: ',
21 '': 'Other languages: '
27 #indir, outdir = sys.argv[1:]
29 # FIXME: looks dangerous!
33 html_files = glob.glob( os.path.join(indir, '*.html') )
35 # messy way to get all languages
37 for file in html_files:
38 file_split = file.split('.')
39 if (len(file_split) == 2):
46 langs = list(langs_set)
49 def makeFooter(currentLang):
50 text = "<p id=\"languages\">\n"
51 text += lang_other_langs[currentLang]
52 for i in range(len(langs)):
54 if (l == currentLang):
56 text += "<a href=\"index"
60 text += lang_lookup[l]
62 if (i < len(langs)-2):
66 # TODO: add link to automatic language selection?
67 # still need to include this page in the new webpages somewhere
72 for file in html_files:
73 file_split = file.split('.')
74 # we want to strip the .html
75 out_filename = os.path.basename(file_split[0])
76 if (len(file_split) == 2):
82 out_filename += '.'+lang
84 # I can't get the previous name to work
85 out_filename = os.path.basename(file)
87 # translation links should point to translations
88 lines = open(file).readlines()
92 lang_footer = makeFooter(lang)
94 outfile = open( os.path.join(outdir, out_filename), 'w')
96 # avoid external links
97 if ((line.find("href") >= 0) and (line.find("http")==-1)):
98 # eventually we want to do this, but I can't get it to work.
99 # waiting for help with apache (?)
100 # line = line.replace(".html", "."+lang)
105 line = line.replace(".html", text)
106 if (line.find("<!-- FOOTER -->") >= 0):
107 outfile.write( lang_footer )