]> git.donarmstrong.com Git - lilypond.git/blobdiff - buildscripts/translations-status.py
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / buildscripts / translations-status.py
old mode 100755 (executable)
new mode 100644 (file)
index 215c7be..c931993
@@ -19,19 +19,15 @@ import string
 import os
 
 import langdefs
+import buildlib
 
 def progress (str):
     sys.stderr.write (str + '\n')
 
 progress ("translations-status.py")
 
-buildscript_dir = sys.argv[1]
-
 _doc = lambda s: s
 
-sys.path.append (buildscript_dir)
-import buildlib
-
 # load gettext messages catalogs
 translation = langdefs.translation
 
@@ -50,9 +46,11 @@ checkers_re = re.compile (r'^@c\s+Translation\s*checkers\s*:\s*(.*?)$',
                           re.M | re.I)
 status_re = re.compile (r'^@c\s+Translation\s*status\s*:\s*(.*?)$', re.M | re.I)
 post_gdp_re = re.compile ('post.GDP', re.I)
-untranslated_node_str = 'UNTRANSLATED NODE: IGNORE ME'
+untranslated_node_str = '@untranslated'
 skeleton_str = '-- SKELETON FILE --'
 
+section_titles_string = _doc ('Section titles')
+last_updated_string = _doc (' <p><i>Last updated %s</i></p>\n')
 detailed_status_heads = [_doc ('Translators'), _doc ('Translation checkers'),
                          _doc ('Translated'), _doc ('Up to date'),
                          _doc ('Other info')]
@@ -210,6 +208,7 @@ class TranslatedTelyDocument (TelyDocument):
             self.translation = translation[self.language]
         else:
             self.translation = lambda x: x
+        self.title = self.translation (self.title)
 
         ## record authoring information
         m = translators_re.search (self.contents)
@@ -248,7 +247,7 @@ class TranslatedTelyDocument (TelyDocument):
 
         ## calculate how much the file is outdated
         (diff_string, error) = \
-            buildlib.check_translated_doc (masterdocument.filename, self.contents)
+            buildlib.check_translated_doc (masterdocument.filename, self.filename, self.contents)
         if error:
             sys.stderr.write ('warning: %s: %s' % (self.filename, error))
             self.uptodate_percentage = None
@@ -274,7 +273,12 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
 setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
                 self.uptodate_percentage = alternative
 
-    def completeness (self, formats=['long']):
+    def completeness (self, formats=['long'], translated=False):
+        if translated:
+            translation = self.translation
+        else:
+            translation = lambda x: x
+
         if isinstance (formats, str):
             formats = [formats]
         p = self.translation_percentage
@@ -284,9 +288,15 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
             status = 'fully translated'
         else:
             status = 'partially translated'
-        return dict ([(f, format_table[status][f] % locals()) for f in formats])
+        return dict ([(f, translation (format_table[status][f]) % locals())
+                      for f in formats])
+
+    def uptodateness (self, formats=['long'], translated=False):
+        if translated:
+            translation = self.translation
+        else:
+            translation = lambda x: x
 
-    def uptodateness (self, formats=['long']):
         if isinstance (formats, str):
             formats = [formats]
         p = self.uptodate_percentage
@@ -301,7 +311,7 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
             if f == 'color' and p != None:
                 l['color'] = percentage_color (p)
             else:
-                l[f] = format_table[status][f] % locals ()
+                l[f] = translation (format_table[status][f]) % locals ()
         return l
 
     def gdp_status (self):
@@ -338,6 +348,9 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
         return s
 
     def html_status (self, numbering=SectionNumber ()):
+        if self.title == 'Untitled':
+            return ''
+
         if self.level[1] == 0: # if self is a master document
             s = '''<table align="center" border="2">
  <tr align="center">
@@ -345,8 +358,9 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
             s += ''.join (['  <th>%s</th>\n' % self.translation (h)
                            for h in detailed_status_heads])
             s += ' </tr>\n'
-            s += ' <tr align="left">\n  <td>Section titles<br>(%d)</td>\n' \
-                % sum (self.masterdocument.word_count)
+            s += ' <tr align="left">\n  <td>%s<br>(%d)</td>\n' \
+                % (self.translation (section_titles_string),
+                   sum (self.masterdocument.word_count))
 
         else:
             s = ' <tr align="left">\n  <td>%s<br>(%d)</td>\n' \
@@ -359,16 +373,16 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
         else:
             s += '  <td></td>\n' * 2
 
-        c = self.completeness (['color', 'short'])
+        c = self.completeness (['color', 'short'], translated=True)
         s += '  <td><span style="background-color: #%(color)s">\
 %(short)s</span></td>\n' % {'color': c['color'],
-                           'short': self.translation (c['short'])}
+                           'short': c['short']}
 
         if self.partially_translated:
-            u = self.uptodateness (['short', 'color'])
+            u = self.uptodateness (['short', 'color'], translated=True)
             s += '  <td><span style="background-color: #%(color)s">\
 %(short)s</span></td>\n' % {'color': u['color'],
-                           'short': self.translation (u['short'])}
+                           'short': u['short']}
         else:
             s += '  <td></td>\n'
 
@@ -495,7 +509,7 @@ progress ("Generating status pages...")
 
 date_time = buildlib.read_pipe ('LANG= date -u')[0]
 
-main_status_html = ' <p><i>Last updated %s</i></p>\n' % date_time
+main_status_html = last_updated_string % date_time
 main_status_html += '\n'.join ([doc.html_status () for doc in master_docs])
 
 html_re = re.compile ('<html>', re.I)
@@ -513,6 +527,8 @@ main_status_page = end_body_re.sub (main_status_html + '\n</body>',
 open ('translations.html.in', 'w').write (main_status_page)
 
 for l in enabled_languages:
+    date_time = buildlib.read_pipe ('LANG=%s date -u' % l)[0]
+    lang_status_pages[l] = translation[l] (last_updated_string) % date_time + lang_status_pages[l]
     lang_status_page = html_re.sub (html_header, lang_status_pages[l])
     html_status = '\n'.join ([doc.translations[l].html_status ()
                               for doc in master_docs