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):
48 langs = list(langs_set)
51 def makeFooter(currentLang, currentPage):
52 text = "<p id=\"languages\">\n"
53 text += lang_other_langs[currentLang]
54 for i in range(len(langs)):
56 if (l == currentLang):
63 text += lang_lookup[l]
65 if (i < len(langs)-2):
69 # TODO: add link to automatic language selection?
70 # still need to include this page in the new webpages somewhere
75 for file in html_files:
76 file_split = file.split('.')
77 # we want to strip the .html
78 out_filename = os.path.basename(file_split[0])
79 if (len(file_split) == 2):
82 # possibly necessary for automatic language selection
83 file_symlink =file.replace(".html", ".en.html")
84 os.symlink (file, file_symlink)
88 out_filename += '.'+lang
90 # I can't get the previous name to work
91 out_filename = os.path.basename(file)
93 # translation links should point to translations
94 lines = open(file).readlines()
99 lang_footer = makeFooter(lang, out_filename.split('.')[0])
101 outfile = open( out_filename, 'w')
103 # avoid external links
104 if ((line.find("href") >= 0) and (line.find("http")==-1)):
105 # eventually we want to do this, but I can't get it to work.
106 # waiting for help with apache (?)
107 # line = line.replace(".html", "."+lang)
112 line = line.replace(".html", text)
113 if ((line.find("href") >= 0) and
114 (line.find("http")==-1) and
115 (line.find("pdf") >= 0)):
120 line = line.replace(".pdf", text)
123 if (line.find("<!-- FOOTER -->") >= 0):
124 outfile.write( lang_footer )