4 ## This is web_post.py. This script deals with translations
5 ## in the "make website" target.
19 'es': 'Otros idiomas: ',
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, currentPage):
50 text = "<p id=\"languages\">\n"
51 text += lang_other_langs[currentLang]
52 for i in range(len(langs)):
54 if (l == currentLang):
61 text += lang_lookup[l]
63 if (i < len(langs)-2):
67 # TODO: add link to automatic language selection?
68 # still need to include this page in the new webpages somewhere
73 for file in html_files:
74 file_split = file.split('.')
75 # we want to strip the .html
76 out_filename = os.path.basename(file_split[0])
77 if (len(file_split) == 2):
83 out_filename += '.'+lang
85 # I can't get the previous name to work
86 out_filename = os.path.basename(file)
88 # translation links should point to translations
89 lines = open(file).readlines()
94 lang_footer = makeFooter(lang, out_filename.split('.')[0])
96 outfile = open( os.path.join(outdir, out_filename), 'w')
98 # avoid external links
99 if ((line.find("href") >= 0) and (line.find("http")==-1)):
100 # eventually we want to do this, but I can't get it to work.
101 # waiting for help with apache (?)
102 # line = line.replace(".html", "."+lang)
107 line = line.replace(".html", text)
108 if ((line.find("href") >= 0) and
109 (line.find("http")==-1) and
110 (line.find("pdf") >= 0)):
115 line = line.replace(".pdf", text)
118 if (line.find("<!-- FOOTER -->") >= 0):
119 outfile.write( lang_footer )