X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=buildscripts%2Ftranslations-status.py;h=4180ea86722c925bc4250e61311a4832735a0c34;hb=991397236e538ad998c767eda42861b553a0624f;hp=215c7bee0a5dffb55820d71e5706bbc7c9a6f047;hpb=89607d16117264aa9207826b80afea6eea737cc0;p=lilypond.git diff --git a/buildscripts/translations-status.py b/buildscripts/translations-status.py index 215c7bee0a..4180ea8672 100755 --- a/buildscripts/translations-status.py +++ b/buildscripts/translations-status.py @@ -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 ('

Last updated %s

\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) @@ -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 = ''' @@ -345,8 +358,9 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative)) s += ''.join ([' \n' % self.translation (h) for h in detailed_status_heads]) s += ' \n' - s += ' \n \n' \ - % sum (self.masterdocument.word_count) + s += ' \n \n' \ + % (self.translation (section_titles_string), + sum (self.masterdocument.word_count)) else: s = ' \n \n' \ @@ -359,16 +373,16 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative)) else: s += ' \n' * 2 - c = self.completeness (['color', 'short']) + c = self.completeness (['color', 'short'], translated=True) s += ' \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 += ' \n' % {'color': u['color'], - 'short': self.translation (u['short'])} + 'short': u['short']} else: s += ' \n' @@ -495,7 +509,7 @@ progress ("Generating status pages...") date_time = buildlib.read_pipe ('LANG= date -u')[0] -main_status_html = '

Last updated %s

\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 ('', re.I) @@ -513,6 +527,8 @@ main_status_page = end_body_re.sub (main_status_html + '\n', 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
%s
Section titles
(%d)
%s
(%d)
%s
(%d)
\ %(short)s\ %(short)s