4 ## This is web_post.py. This script deals with translations
5 ## in the "make website" target.
19 'es': 'Otros idiomas: ',
20 'fr': 'Autres langues : ',
21 '': 'Other languages: '
27 #indir, outdir = sys.argv[1:]
29 # FIXME: looks dangerous!
35 html_files = glob.glob( '*.html' )
37 # messy way to get all languages
39 for file in html_files:
40 file_split = file.split('.')
41 if (len(file_split) == 2):
47 # make sure it's a real language
48 if (not (lang == "en")):
50 langs = list(langs_set)
53 def makeFooter(currentLang, currentPage):
54 text = "<p id=\"languages\">\n"
55 text += lang_other_langs[currentLang]
56 for i in range(len(langs)):
58 if (l == currentLang):
65 text += lang_lookup[l]
67 if (i < len(langs)-2):
71 # TODO: add link to automatic language selection?
72 # still need to include this page in the new webpages somewhere
77 for file in html_files:
78 file_split = file.split('.')
79 # we want to strip the .html
80 out_filename = os.path.basename(file_split[0])
81 if (len(file_split) == 2):
84 # possibly necessary for automatic language selection
85 file_symlink =file.replace(".html", ".en.html")
86 if (not (os.path.exists(file_symlink))):
87 os.symlink (file, file_symlink)
94 out_filename += '.'+lang
96 # I can't get the previous name to work
97 out_filename = os.path.basename(file)
99 # translation links should point to translations
100 lines = open(file).readlines()
105 lang_footer = makeFooter(lang, out_filename.split('.')[0])
107 outfile = open( out_filename, 'w')
109 # avoid external links
110 if ((line.find("href") >= 0) and (line.find("http")==-1)):
111 # eventually we want to do this, but I can't get it to work.
112 # waiting for help with apache (?)
113 # line = line.replace(".html", "."+lang)
118 line = line.replace(".html", text)
119 if ((line.find("href") >= 0) and
120 (line.find("http")==-1) and
121 (line.find("pdf") >= 0)):
126 line = line.replace(".pdf", text)
129 if (line.find("<!-- FOOTER -->") >= 0):
130 outfile.write( lang_footer )