X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fbuild%2Fwebsite_post.py;h=317cf5ac9cd26dd2b6ba38bbfe764bb5f857090f;hb=f6dc5e44d6bac45c3997461208eec4e246748d9d;hp=14905a85488130f213b44d5f7538b581fc8dd45f;hpb=17463ba49a755dca5682ba18af450c198d94e050;p=lilypond.git diff --git a/scripts/build/website_post.py b/scripts/build/website_post.py index 14905a8548..317cf5ac9c 100644 --- a/scripts/build/website_post.py +++ b/scripts/build/website_post.py @@ -1,133 +1,220 @@ #!@PYTHON@ #-*- coding: utf-8 -*- -## This is web_post.py. This script deals with translations -## in the "make website" target. +##### This is website_post.py. This script deals with translations +##### in the "make website" target. import sys import os import glob - -#### Translation data -lang_lookup = { - 'fr': 'français', - 'es': 'español', - '': 'english' -} - -lang_other_langs = { - 'es': 'Otros idiomas: ', - 'fr': 'Autres langues : ', - '': 'Other languages: ' -} - - -#### Actual program - -#indir, outdir = sys.argv[1:] - -# FIXME: looks dangerous! -indir = sys.argv[1] -outdir=indir - -os.chdir(indir) - +import re + +###### Translation data, move out, see create-weblinks-itexi.py +translations = { + 'cs': { + 'English': 'Äesky', + 'Other languages': 'Jiné jazyky', + }, + 'de': { + 'English': 'Deutsch', + 'Other languages': 'Andere Sprachen', + }, + 'es': { + 'English': 'Español', + 'Other languages': 'Otros idiomas', + }, + 'fr': { + 'English': 'Français', + 'Other languages': 'Autres langues', + }, + 'hu': { + 'English': 'Magyar', + 'Other languages': 'Más nyelvek', + }, + 'it': { + 'English': 'Italiano', + 'Other languages': 'Altre lingue', + }, + 'ja': { + 'English': 'æ¥æ¬èª', + 'Other languages': 'ä»ã®è¨èª', + }, + 'nl': { + 'English': 'Nederlands', + 'Other languages': 'Andere talen', + }, + 'zh': { + 'English': 'ä¸æ', + 'Other languages': 'å ¶ä»è¯è¨', + }, + } + +# needs at least: make -C po or make -C Documentation/po +HAVE_GETTEXT = False + +#### this breaks on lilypond.org +# Keep some freakin' gettext compatibility +#if HAVE_GETTEXT: +# import lilylib as ly; +# global _;_=ly._ +#else: # poor mans translation +# def _ (string, lang=os.environ['LANG']): +# return translations.get (lang.split ('_')[0], {}).get (string, string) + +#### this works on lilypond.org +def _ (string, lang): + return translations.get (lang.split ('_')[0], {}).get (string, string) + + +exclude_manuals = [ + '/music-glossary', + '/snippets', + '/internals', + '/contributor' +] + +###### Actual program + +dir = sys.argv[1] + +os.chdir(dir) html_files = glob.glob( '*.html' ) -# messy way to get all languages + +### 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] - # make sure it's a real language - if (not (lang == "en")): - langs_set.add(lang) + file_split = file.split('.') + if (len(file_split) == 2): + # it's English + lang = '' + elif (len(file_split) == 3): + # it's a translation + lang = file_split[1] + # make sure it's a translated language + if lang != "en": + langs_set.add(lang) langs = list(langs_set) langs.sort() -def makeFooter(currentLang, currentPage): - text = "
\n" - text += lang_other_langs[currentLang] - 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 - +### helper functions +def addLangExt(filename, lang, ext): + text = filename + exclude = 0 + for dir in exclude_manuals: + if (text.find(dir) >= 0): + exclude = 1 + if (not (exclude or (lang==""))): + text += "." + lang + text += "." + ext + return text + +def makeFooter (filename, currentLang): + footer = '''
+
+%(other)s: %(lst)s.
+
+%(browser_language)s
+