From 315c66261c96d84336df3bc0499327ab5f91521f Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Thu, 4 Mar 2010 20:54:18 +0000 Subject: [PATCH] Web build: add footer for language selection. --- Documentation/contributor/website-work.itexi | 4 +-- scripts/build/{web_post.py => website_post.py} | 49 +++++++++++++++++++++++++- website.make | 2 +- 3 files changed, 51 insertions(+), 4 deletions(-) rename scripts/build/{web_post.py => website_post.py} (50%) diff --git a/Documentation/contributor/website-work.itexi b/Documentation/contributor/website-work.itexi index b27d9bbf06..14b6b301b0 100644 --- a/Documentation/contributor/website-work.itexi +++ b/Documentation/contributor/website-work.itexi @@ -80,7 +80,7 @@ diff -u $DEST/extract_texi_filenames.py $GIT/scripts/build/extract_texi_filename diff -u $DEST/create-version-itexi.py $GIT/scripts/build/create-version-itexi.py diff -u $DEST/create-weblinks-itexi.py $GIT/scripts/build/create-weblinks-itexi.py diff -u $DEST/mass-link.py $GIT/scripts/build/mass-link.py -diff -u $DEST/web_post.py $GIT/scripts/build/web_post.py +diff -u $DEST/website_post.py $GIT/scripts/build/website_post.py @end verbatim If the changes look ok, make them trusted: @@ -96,7 +96,7 @@ cp $GIT/scripts/build/extract_texi_filenames.py $DEST/extract_texi_filenames.py cp $GIT/scripts/build/create-version-itexi.py $DEST/create-version-itexi.py cp $GIT/scripts/build/create-weblinks-itexi.py $DEST/create-weblinks-itexi.py cp $GIT/scripts/build/mass-link.py $DEST/mass-link.py -cp $GIT/scripts/build/web_post.py $DEST/web_post.py +cp $GIT/scripts/build/website_post.py $DEST/website_post.py @end verbatim Build the website: diff --git a/scripts/build/web_post.py b/scripts/build/website_post.py similarity index 50% rename from scripts/build/web_post.py rename to scripts/build/website_post.py index 20a3bdb3d6..8018f3ad62 100644 --- a/scripts/build/web_post.py +++ b/scripts/build/website_post.py @@ -1,4 +1,5 @@ #!@PYTHON@ +#-*- coding: utf-8 -*- ## This is web_post.py. This script deals with translations ## in the "make website" target. @@ -7,6 +8,12 @@ import sys import os import glob +lang_lookup = { + 'fr': 'français', + 'es': 'español', + '': 'english' +} + #indir, outdir = sys.argv[1:] # FIXME: looks dangerous! @@ -15,6 +22,42 @@ outdir=indir html_files = glob.glob( os.path.join(indir, '*.html') ) +# messy way to get all languages +langs_set = set() +for file in html_files: + file_split = file.split('.') + if (len(file_split) == 2): + # it's English + lang = '' + else: + # it's a translation + lang = file_split[1] + langs_set.add(lang) +langs = list(langs_set) +langs.sort() + +def makeFooter(currentLang): + text = "

\n" + text += "Other languages: " + for i in range(len(langs)): + l = langs[i] + if (l == currentLang): + continue + text += "" + text += lang_lookup[l] + text += "" + if (i < len(langs)-2): + text += ", " + else: + text += ".\n" + # TODO: add link to automatic language selection? + # still need to include this page in the new webpages somewhere + text += "

\n" + return text + for file in html_files: file_split = file.split('.') @@ -36,14 +79,18 @@ for file in html_files: # ick os.remove(file) + lang_footer = makeFooter(lang) + outfile = open( os.path.join(outdir, out_filename), 'w') for line in lines: # avoid external links - if ((line.find("href") > 0) and (line.find("http")==-1)): + if ((line.find("href") >= 0) and (line.find("http")==-1)): # eventually we want to do this, but I can't get it to work. # waiting for help with apache (?) # line = line.replace(".html", "."+lang) line = line.replace(".html", "."+lang+".html") + if (line.find("") >= 0): + outfile.write( lang_footer ) outfile.write(line) outfile.close() diff --git a/website.make b/website.make index a431d50550..4657578620 100644 --- a/website.make +++ b/website.make @@ -36,7 +36,7 @@ EXTRACT_TEXI_FILENAMES=python $(script-dir)/extract_texi_filenames.py CREATE_VERSION=python $(script-dir)/create-version-itexi.py CREATE_WEBLINKS=python $(script-dir)/create-weblinks-itexi.py MASS_LINK=python $(script-dir)/mass-link.py -WEB_POST=python $(script-dir)/web_post.py +WEB_POST=python $(script-dir)/website_post.py SERVER_FILES=$(top-src-dir)/Documentation/web/server/ -- 2.11.4.GIT