]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/build/website_post.py
Doc-ca: Priority II Catalan translation
[lilypond.git] / scripts / build / website_post.py
index f27b5786f63ba56dd523e9259e26ed99bf48223b..a6fafdc01251bb38559f84d2dc3c337855881029 100644 (file)
@@ -1,7 +1,7 @@
 #!@PYTHON@
 #-*- coding: utf-8 -*-
 
-##### This is web_post.py. This script deals with translations
+##### This is website_post.py. This script deals with translations
 ##### in the "make website" target.
 
 import sys
@@ -11,6 +11,14 @@ import re
 
 ###### Translation data, move out, see create-weblinks-itexi.py
 translations = {
+    'ca': {
+        'English': 'Català',
+        'Other languages': 'Altres idiomes',
+        },
+    'cs': {
+        'English': 'Česky',
+        'Other languages': 'Jiné jazyky',
+        },
     'de': {
         'English': 'Deutsch',
         'Other languages': 'Andere Sprachen',
@@ -32,16 +40,20 @@ translations = {
         'Other languages': 'Altre lingue',
         },
     'ja': {
-        'English': 'Japanese',
+        'English': '日本語',
         'Other languages': '他の言語',
         },
     'nl': {
         'English': 'Nederlands',
         'Other languages': 'Andere talen',
         },
+    'zh': {
+        'English': '中文',
+        'Other languages': '其他语言',
+        },
     }
 
-# needs at least: make -C po or makeC Documentation/po
+# needs at least: make -C po or make -C Documentation/po
 HAVE_GETTEXT = False
 
 ####  this breaks on lilypond.org
@@ -103,12 +115,14 @@ def addLangExt(filename, lang, ext):
     return text
 
 def makeFooter (filename, currentLang):
-    # TODO: add link to automatic language selection?
-    # still need to include this page in the new webpages somewhere
     footer = '''<p id="languages">
+<!-- These links were autogenerated by %(me)s -->
 %(other)s: %(lst)s.
+<br>
+%(browser_language)s
 </p>
 '''
+    me = sys.argv[0]
     def link (lang):
         str = '''<a href="%(file_name)s">%(language_name)s</a>'''
         file_name = addLangExt (filename, lang, 'html')
@@ -116,6 +130,9 @@ def makeFooter (filename, currentLang):
         return str % locals ()
     lst = ', '.join ([link (lang) for lang in langs if lang != currentLang])
     other = _ ('Other languages', currentLang)
+    browser_lang = _ ('About <a href="%s">automatic language selection</a>.', currentLang)
+    browser_language_url = "http://www.lilypond.org/website/misc/browser-language"
+    browser_language = browser_lang % browser_language_url
     return footer % locals ()
 
 def getLocalHref(line):
@@ -145,7 +162,7 @@ for file in html_files:
         lang = ''
         # possibly necessary for automatic language selection
         file_symlink = file.replace(".html", ".en.html")
-        if (not (os.path.exists(file_symlink))):
+        if not os.path.lexists (file_symlink):
             os.symlink (file, file_symlink)
     elif (len(file_split) == 3):
         # it's a translation
@@ -170,13 +187,32 @@ for file in html_files:
         ### alter links as appropriate
         link = getLocalHref(line)
         if (link != ""):
-            # quesitonable
-            if (link.endswith(".html")):
-               langlink = addLangExt(link[:-5], lang, "html")
-                line = line.replace(link, langlink)
-            if (link.endswith(".pdf")):
-               langlink = addLangExt(link[:-4], lang, "pdf")
-                line = line.replace(link, langlink)
+            # questionable
+            if (not link.startswith("../doc/")):
+                if (link.endswith(".html")):
+                    langlink = addLangExt(link[:-5], lang, "html")
+                    line = line.replace(link, langlink)
+                if (link.endswith(".pdf")):
+                    langlink = addLangExt(link[:-4], lang, "pdf")
+                    line = line.replace(link, langlink)
+        ### add google tracker header
+        if (line.find("</head>") >= 0):
+            outfile.write("""<!-- Google tracking !-->
+<script src="http://www.google-analytics.com/urchin.js"
+type="text/javascript">
+</script>
+<script type="text/javascript">
+_uacct = "UA-68969-1";
+urchinTracker();
+</script>
+""");
+        #### add google tracker goals
+        if (line.find("href=\"http://download.linuxaudio.org") >= 0):
+            # TODO: more ugly hardcoding to make releases hard. :(
+            if (line.find('2.16') >= 0):
+                line = line.replace('a href=', 'a onClick=\"javascript:urchinTracker(\'/download/v2.16\');\" href=')
+            elif (line.find('2.17') >= 0):
+                line = line.replace('a href=', 'a onClick=\"javascript:urchinTracker(\'/download/v2.17\');\" href=')
         ### add language selection footer
         if (line.find("<div id=\"verifier_texinfo\">") >= 0):
             outfile.write("<div id=\"footer\">\n")
@@ -185,4 +221,3 @@ for file in html_files:
             outfile.write("</div>\n")
         outfile.write(line)
     outfile.close()
-