From: Graham Percival Date: Thu, 4 Mar 2010 20:54:18 +0000 (+0000) Subject: Web build: add footer for language selection. X-Git-Tag: release/2.13.16-1~60 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=315c66261c96d84336df3bc0499327ab5f91521f;p=lilypond.git Web build: add footer for language selection. --- 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/web_post.py deleted file mode 100644 index 20a3bdb3d6..0000000000 --- a/scripts/build/web_post.py +++ /dev/null @@ -1,49 +0,0 @@ -#!@PYTHON@ - -## This is web_post.py. This script deals with translations -## in the "make website" target. - -import sys -import os -import glob - -#indir, outdir = sys.argv[1:] - -# FIXME: looks dangerous! -indir = sys.argv[1] -outdir=indir - -html_files = glob.glob( os.path.join(indir, '*.html') ) - - -for file in html_files: - file_split = file.split('.') - # we want to strip the .html - out_filename = os.path.basename(file_split[0]) - if (len(file_split) == 2): - # it's English - lang = '' - else: - # it's a translation - lang = file_split[1] - out_filename += '.'+lang - -# I can't get the previous name to work - out_filename = os.path.basename(file) - - # translation links should point to translations - lines = open(file).readlines() - # ick - os.remove(file) - - 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)): -# 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") - outfile.write(line) - outfile.close() - diff --git a/scripts/build/website_post.py b/scripts/build/website_post.py new file mode 100644 index 0000000000..8018f3ad62 --- /dev/null +++ b/scripts/build/website_post.py @@ -0,0 +1,96 @@ +#!@PYTHON@ +#-*- coding: utf-8 -*- + +## This is web_post.py. This script deals with translations +## in the "make website" target. + +import sys +import os +import glob + +lang_lookup = { + 'fr': 'français', + 'es': 'español', + '': 'english' +} + +#indir, outdir = sys.argv[1:] + +# FIXME: looks dangerous! +indir = sys.argv[1] +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('.') + # we want to strip the .html + out_filename = os.path.basename(file_split[0]) + if (len(file_split) == 2): + # it's English + lang = '' + else: + # it's a translation + lang = file_split[1] + out_filename += '.'+lang + +# I can't get the previous name to work + out_filename = os.path.basename(file) + + # translation links should point to translations + lines = open(file).readlines() + # 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)): +# 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/