]> git.donarmstrong.com Git - lilypond.git/commitdiff
website_post.py: grok all languages.
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 2 Apr 2010 19:19:48 +0000 (21:19 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 2 Apr 2010 19:42:06 +0000 (21:42 +0200)
scripts/build/website_post.py

index f0b20b9fdef224ed713935d092c02ef20f837d76..368e88842e16afb61f6ce0af276e67d52ca2cb14 100644 (file)
@@ -9,18 +9,45 @@ import os
 import glob
 import re
 
-###### Translation data
-lang_lookup = {
-    'fr': 'français',
-    'es': 'español',
-    '': 'english'
-}
-
-lang_other_langs = {
-    'es': 'Otros idiomas: ',
-    'fr': 'Autres langues : ',
-    '': 'Other languages: '
-}
+###### Translation data, move out, see create-weblinks-itexi.py
+translations = {
+    '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: ',
+        },
+    'ja': {
+        'English': 'Japanese',
+        'Other languages: ': '他の言語: ',
+        },
+    'nl': {
+        'English': 'Nederlands',
+        'Other languages: ': 'Andere talen: ',
+        },
+    }
+
+# needs at least: make -C po or make- C Documentation/po
+HAVE_GETTEXT = False
+
+# 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)
+
 
 exclude_manuals = [
     '/music-glossary',
@@ -48,7 +75,7 @@ for file in html_files:
         # it's a translation
         lang = file_split[1]
     # make sure it's a translated language
-    if (not (lang == "en")):
+    if lang != "en":
         langs_set.add(lang)
 langs = list(langs_set)
 langs.sort()
@@ -68,20 +95,16 @@ def addLangExt(filename, lang, ext):
 
 def makeFooter(filename, currentLang):
     text = "<p id=\"languages\">\n"
-    text += lang_other_langs[currentLang]
-    for i in range(len(langs)):
-        lang = langs[i]
+    text += _ ('Other languages: ', currentLang)
+    for lang in langs:
         if (lang == currentLang):
             continue
         text += "<a href=\""
        text += addLangExt(filename, lang, "html")
         text += "\">"
-        text += lang_lookup[lang]
-        text += "</a>"
-        if (i < len(langs)-2):
-            text += ", "
-        else:
-            text += ".\n"
+        text += _ ('English', lang)
+        text += "</a>, "
+    text = text[:-2] + '.\n'
     # TODO: add link to automatic language selection?
     # still need to include this page in the new webpages somewhere
     text += "</p>\n"
@@ -134,7 +157,6 @@ for file in html_files:
 
     lang_footer = makeFooter(file_base, lang)
 
-
     ### alter file
     for line in lines:
         ### alter links as appropriate