X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fauxiliar%2Ftranslations-status.py;h=221746360be79e305bf270fa13584f9fd1f6bf24;hb=1f6e0e7a473c909c5577cba57d93e5a1c6f9f975;hp=c4f09ac2ec4bc98f84983f328f9643968f1ddafe;hpb=86012c77b936acd21c115e532783cea595780a48;p=lilypond.git diff --git a/scripts/auxiliar/translations-status.py b/scripts/auxiliar/translations-status.py index c4f09ac2ec..221746360b 100755 --- a/scripts/auxiliar/translations-status.py +++ b/scripts/auxiliar/translations-status.py @@ -10,6 +10,19 @@ USAGE: cd Documentation && translations-status.py Update word counts in: contributor/doc-translation-list.itexi + +TODO: + * using markup = TexiMarkup (), html tables (columns) + are evenly spaced and bit too wide. This can + be fixed by using + @multitable @columnfractions 0 0 0 0 0 0 0 0, + but with that, PDF and info output get borked. + * in info and PDF, columns have too little separation + * using markup = HTMLMarkup (), we get nice +
Last updated %s
\n') +last_updated_string = _doc ('Last updated %s') detailed_status_heads = [_doc ('Translators'), _doc ('Translation checkers'), _doc ('Translated'), _doc ('Up to date'), _doc ('Other info')] @@ -178,11 +191,29 @@ def tely_word_count (tely_doc): return [len (space_re.split (n)) for n in nodes] class HTMLMarkup (object): + texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*- +@c This file was generated by translation-status.py -- DO NOT EDIT! +@ignore + Translation of GIT committish: 0 +@end ignore + +''' + texi_footer = ''' +''' + def texi (self, string): + return (self.texi_header + + ''' +@ifnothtml +Translation status currently only available in HTML. +@end ifnothtml +''' + + string + + self.texi_footer) def entity (self, name, string='', attributes=[]): attr_list = ''.join ([' %s="%s"' % x for x in attributes]) return '<%(name)s%(attr_list)s>%(string)s%(name)s>' % locals () def paragraph (self, string=''): - return self.entity ('p') + return self.entity ('p', string) def table (self, string): return self.entity ('table', string, [('align', 'center'), ('border', '2')]) def row (self, string, attributes=[]): @@ -190,7 +221,7 @@ class HTMLMarkup (object): headrow = row def headcell (self, string, attributes=[]): return self.entity ('th', string, attributes) - def cell (self, string, attributes=[]): + def cell (self, string='', attributes=[]): return self.entity ('td', string, attributes) def newline (self, attributes=[]): return self.entity ('br', '', attributes)[:-5] @@ -198,38 +229,74 @@ class HTMLMarkup (object): return self.entity ('span', string, attributes) def small (self, string, attributes=[]): return self.entity ('small', string, attributes) + def emph (self, string, attributes=[]): + return self.entity ('em', string, attributes) class TexiMarkup (HTMLMarkup): + def texi (self, string): + return (self.texi_header + + self.html (''' + +''') + + self.columnfraction_disaster (self.itemtab_disaster (string)) + + self.texi_footer) + def itemtab_disaster (self, string): + return string.replace ('''item \n@tab ''', '''item +''') + def columnfraction_disaster (self, string): + if False: + # nice trick for html-only + return string.replace ('@multitable', '@multitable @columnfractions 0 0 0 0 0 0 0 0 0 0') + tables = re.findall ('(?s)(@multitable)(.*?)(@item)', string) + for t in tables: + columns = len (re.findall ('(?s)(\n@tab)', t[1])) + 1 + columnfractions = '@columnfractions ' + (' ' + str (1.0/columns)) * columns + string = string.replace ('@multitable\n', + '@multitable %(columnfractions)s\n' % locals (), 1) + return string def entity (self, name, string='', attributes=[]): return ''' @%(name)s %(string)s -@end %(name)s -''' % locals () +@end %(name)s''' % locals () def paragraph (self, string=''): return ''' %(string)s''' % locals () def table (self, string): - return self.entity ('multitable', string) + # Ugh, makeinfo is fine without @columnfractions + # but texi2html 1.82 barfs: `empty multicolumn' + return (self.entity ('multitable', string)) def headrow (self, string, attributes=[]): return ''' @headitem ''' + string def row (self, string, attributes=[]): return ''' @item ''' + string - def cell (self, string, attributes=[]): + def cell (self, string='', attributes=[]): return ''' @tab ''' + string headcell = cell def newline (self): return ''' -@* ''' +@* +''' def html (self, string): return self.entity ('ifhtml', self.entity ('html', string)) + def nothtml (self, string): + return self.entity ('ifnothtml', string) def span (self, string, attributes=[]): - return self.html (HTMLMarkup.span (self, string, attributes)) + return (self.html (HTMLMarkup ().span (string, attributes)) + + self.nothtml (string)) def small (self, string, attributes=[]): - return self.html (HTMLMarkup.small (self, string, attributes)) + return (self.html (HTMLMarkup ().small (string, attributes)) + + self.nothtml (string)) + def command (self, name, string): + return '@%(name)s{%(string)s}' % locals () + def emph (self, string, attributes=[]): + return self.command ('emph', string) class TelyDocument (object): def __init__ (self, filename): @@ -304,8 +371,8 @@ class TranslatedTelyDocument (TelyDocument): and (not self.translators or not self.translators[0]) and not 'macros.itexi' in self.filename): error (self.filename + ''': error: no translator name found -please specify one ore more lines in the master file -@c Translator: FirstName LastName[, FirstName LastName]..''') + please specify one ore more lines in the master file + @c Translator: FirstName LastName[, FirstName LastName]..''') self.checkers = [] m = checkers_re.findall (self.contents) if m: @@ -418,7 +485,7 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative)) if self.partially_translated: s += markup.newline ().join (self.translators + ['']) if self.checkers: - s += markup.small (markup.newline ().join (self.checkers + [''])) + s += markup.newline ().join ([markup.small (x) for x in self.checkers + ['']]) c = self.completeness (['color', 'long']) s += markup.span ('%(long)s' % c, [('style', 'background-color: #%(color)s' % c)]) s += markup.newline () @@ -441,9 +508,9 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative)) for h in detailed_status_heads])), [('align', 'center')]) + markup.row ( - (markup.cell (((self.translation (section_titles_string) - + markup.newline () - + '%d' % sum (self.masterdocument.word_count))) % self.__dict__, + (markup.cell ((self.translation (section_titles_string) + + markup.newline () + + '%d' % sum (self.masterdocument.word_count)), [('title',filename)]) + self.texi_body (markup, numbering)), [('align','left')]) @@ -458,26 +525,24 @@ setting to %d %%" % (self.filename, self.uptodate_percentage, alternative)) def texi_translators (self, markup): if self.partially_translated: - return ('