#!/usr/bin/env python
-"""
-USAGE: translations-status.py BUILDSCRIPT-DIR LOCALEDIR
-
- This script must be run from Documentation/
-
- Reads template files translations.template.html.in
-and for each LANG in LANGUAGES LANG/translations.template.html.in
- Writes translations.html.in and for each LANG in LANGUAGES
-translations.LANG.html.in
- Writes out/translations-status.txt
- Updates word counts in TRANSLATION
-"""
+'''
+USAGE: cd Documentation && translations-status.py
+
+ Write:
+ translations.itexi
+ <LANG>/translations.itexi
+ out/translations-status.txt
+
+ 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
+ <td title="FILENAME">
+ popups -- do we want that with texi output? -- how?
+ or possibly links to the git archive?
+
+'''
import sys
import re
import string
+import operator
import os
-
+#
import langdefs
import buildlib
space_re = re.compile (r'\s+', re.M)
lilypond_re = re.compile (r'@lilypond({.*?}|(.|\n)*?\n@end lilypond$)', re.M)
node_re = re.compile ('^@node .*?$', re.M)
-title_re = re.compile ('^@(top|chapter|(?:sub){0,2}section|' + \
-'(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?) (.*?)$', re.M)
+title_re = re.compile ('^@(settitle|chapter|top|(?:sub){0,2}section|'
+ '(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?) (.*?)$', re.M)
include_re = re.compile ('^@include (.*?)$', re.M)
-translators_re = re.compile (r'^@c\s+Translators\s*:\s*(.*?)$', re.M | re.I)
-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)
+# allow multiple lines
+translators_re = re.compile (r'^@c[ ]+[Tt]ranslators?[ ]*:[ ]*(.*?)$', re.M)
+checkers_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Cc]heckers?[ ]*:[ ]*(.*?)$', re.M)
+status_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Ss]tatus[ ]*:[ ]*(.*?)$', re.M)
post_gdp_re = re.compile ('post.GDP', re.I)
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')
+last_updated_string = _doc ('Last updated %s')
detailed_status_heads = [_doc ('Translators'), _doc ('Translation checkers'),
_doc ('Translated'), _doc ('Up to date'),
_doc ('Other info')]
'chapter': ('n', 1),
'section': ('n', 2),
'subsection': ('n', 3),
- 'appendix': ('l', 1)
+ 'appendix': ('l', 1),
+ 'appendixsec': ('l', 2),
}
appendix_number_trans = string.maketrans ('@ABCDEFGHIJKLMNOPQRSTUVWXY',
nodes = node_re.split (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', string)
+ def table (self, string):
+ return self.entity ('table', string, [('align', 'center'), ('border', '2')])
+ def row (self, string, attributes=[]):
+ return self.entity ('tr', string, attributes)
+ headrow = row
+ def headcell (self, string, attributes=[]):
+ return self.entity ('th', string, attributes)
+ def cell (self, string='', attributes=[]):
+ return self.entity ('td', string, attributes)
+ def newline (self, attributes=[]):
+ return self.entity ('br', '', attributes)[:-5]
+ def span (self, string, attributes=[]):
+ 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 ('''
+<style type="text/css"><!--
+th { border: 1px solid black; text-align: center; }
+td { border: 1px solid black; text-align: center; }
+!--></style>
+''')
+ + 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 ()
+ def paragraph (self, string=''):
+ return '''
+%(string)s''' % locals ()
+ def table (self, 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=[]):
+ 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 (string, attributes))
+ + self.nothtml (string))
+ def 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):
self.filename = filename
- self.contents = open (filename).read ()
-
+ self.contents = 'GIT committish: 0'
+ if os.path.exists (filename):
+ self.contents = open (filename).read ()
## record title and sectionning level of first Texinfo section
+ self.sectioning = 'unnumbered'
+ self.title = 'Untitled'
m = title_re.search (self.contents)
if m:
+ self.sectioning = m.group (1)
self.title = m.group (2)
- self.level = texi_level [m.group (1)]
- else:
- self.title = 'Untitled'
- self.level = ('u', 1)
+ if not hasattr (self, 'language'):
+ self.language = ''
m = language_re.search (self.contents)
if m:
self.language = m.group (1)
- included_files = [os.path.join (os.path.dirname (filename), t)
+ dir = os.path.dirname (filename).split ('/')[0]
+ if len (dir) == 2:
+ dir += '/'
+ else:
+ dir = ''
+ included_files = [dir + t
for t in include_re.findall (self.contents)]
self.included_files = [p for p in included_files if os.path.exists (p)]
+ def get_level (self):
+ return texi_level [self.sectioning]
+
def print_title (self, section_number):
+ if not hasattr (self, 'level'):
+ self.level = self.get_level ()
return section_number.increase (self.level) + self.title
class TranslatedTelyDocument (TelyDocument):
def __init__ (self, filename, masterdocument, parent_translation=None):
TelyDocument.__init__ (self, filename)
-
self.masterdocument = masterdocument
- if not hasattr (self, 'language') \
- and hasattr (parent_translation, 'language'):
- self.language = parent_translation.language
- if hasattr (self, 'language'):
+ if not hasattr (self, 'language'):
+ self.language = ''
+ if not self.language and parent_translation:
+ self.language = parent_translation.__dict__.get ('language', '')
+ if self.language == 'en':
+ print filename + ': language en specified: set @documentlanguage', self.filename[:2]
+ self.language = ''
+ if not self.language and filename[2] == '/':
+ print filename + ': no language specified: add @documentlanguage', self.filename[:2]
+ self.language = filename[:2]
+ if self.language:
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)
+ self.translators = ['']
+ if parent_translation:
+ self.translators = parent_translation.__dict__.get ('translators', [''])
+ m = translators_re.findall (self.contents)
if m:
- self.translators = [n.strip () for n in m.group (1).split (',')]
- else:
- try:
- self.translators = parent_translation.translators
- except:
- error ('%s: no translator name found, \nplease \
-specify at least one in the master file as a line containing\n\
-@c Translators: FirstName1 LastName1, FirstName2 LastName2' % self.filename)
- m = checkers_re.search (self.contents)
+ self.translators = [n.strip () for n in
+ reduce (operator.add, [n.split (',') for n in m])]
+ if self.language != self.filename[:2]:
+ print 'Barf:', self.filename
+ barf
+ if (not isinstance (self, UntranslatedTelyDocument)
+ 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]..''')
+ self.checkers = []
+ m = checkers_re.findall (self.contents)
if m:
- self.checkers = [n.strip () for n in m.group (1).split (',')]
- elif isinstance (parent_translation, TranslatedTelyDocument):
+ self.checkers = [n.strip () for n in
+ reduce (operator.add, [n.split (',') for n in m])]
+ if not self.checkers and isinstance (parent_translation, TranslatedTelyDocument):
self.checkers = parent_translation.checkers
- else:
- self.checkers = []
## check whether translation is pre- or post-GDP
m = status_re.search (self.contents)
setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
self.uptodate_percentage = alternative
+ def get_level (self):
+ return texi_level ['top']
+
def completeness (self, formats=['long'], translated=False):
if translated:
translation = self.translation
else:
return self.translation (format_table['pre-GDP'])
- def short_html_status (self):
- s = ' <td>'
+ def short_texi_status (self, markup):
+ s = ''
if self.partially_translated:
- s += '<br>\n '.join (self.translators) + '<br>\n'
+ s += markup.newline ().join (self.translators + [''])
if self.checkers:
- s += ' <small>' + \
- '<br>\n '.join (self.checkers) + '</small><br>\n'
-
+ s += markup.newline ().join ([markup.small (x) for x in self.checkers + ['']])
c = self.completeness (['color', 'long'])
- s += ' <span style="background-color: #%(color)s">\
-%(long)s</span><br>\n' % c
-
+ s += markup.span ('%(long)s' % c, [('style', 'background-color: #%(color)s' % c)])
+ s += markup.newline ()
if self.partially_translated:
u = self.uptodateness (['vague', 'color'])
- s += ' <span style="background-color: #%(color)s">\
-%(vague)s</span><br>\n' % u
-
- s += ' </td>\n'
- return s
+ s += markup.span ('%(vague)s' % u, [('style', 'background-color: #%(color)s' % u)])
+ return markup.cell (s, [('title', filename)])
def text_status (self):
s = self.completeness ('abbr')['abbr'] + ' '
-
if self.partially_translated:
s += self.uptodateness ('abbr')['abbr'] + ' '
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">
- <th>%s</th>''' % self.print_title (numbering)
- s += ''.join ([' <th>%s</th>\n' % self.translation (h)
- for h in detailed_status_heads])
- s += ' </tr>\n'
- 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' \
- % (self.print_title (numbering),
- sum (self.masterdocument.word_count))
-
+ def texi_status (self, markup, numbering=SectionNumber ()):
+ return (markup.table (
+ markup.headrow (
+ (markup.headcell (self.print_title (numbering))
+ + ''.join ([markup.headcell (self.translation (h))
+ 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)),
+ [('title',filename)])
+ + self.texi_body (markup, numbering)),
+ [('align','left')])
+ + self.texi_translations (markup, numbering))
+ ) + markup.paragraph ()
+
+ def texi_body (self, markup, numbering):
+ return (self.texi_translators (markup)
+ + self.texi_completeness (markup)
+ + self.texi_uptodateness (markup)
+ + self.texi_gdp (markup))
+
+ def texi_translators (self, markup):
if self.partially_translated:
- s += ' <td>' + '<br>\n '.join (self.translators) + '</td>\n'
- s += ' <td>' + '<br>\n '.join (self.checkers) + '</td>\n'
- else:
- s += ' <td></td>\n' * 2
+ return (markup.cell (markup.newline ().join (self.translators))
+ + markup.cell (markup.newline ().join (self.checkers)))
+ return markup.cell () + markup.cell ()
+ def texi_completeness (self, markup):
c = self.completeness (['color', 'short'], translated=True)
- s += ' <td><span style="background-color: #%(color)s">\
-%(short)s</span></td>\n' % {'color': c['color'],
- 'short': c['short']}
+ return markup.cell (markup.span (c['short'],
+ [('style', 'background-color: #' + c['color'])]))
+ def texi_uptodateness (self, markup):
if self.partially_translated:
u = self.uptodateness (['short', 'color'], translated=True)
- s += ' <td><span style="background-color: #%(color)s">\
-%(short)s</span></td>\n' % {'color': u['color'],
- 'short': u['short']}
- else:
- s += ' <td></td>\n'
-
- s += ' <td>' + self.gdp_status () + '</td>\n </tr>\n'
- s += ''.join ([i.translations[self.language].html_status (numbering)
- for i in self.masterdocument.includes
- if self.language in i.translations])
+ return markup.cell (markup.span (u['short'],
+ [('style', 'background-color: #' + u['color'])]))
+ return markup.cell ()
+
+ def texi_gdp (self, markup):
+ return markup.cell (self.gdp_status ())
+
+ def texi_translations (self, markup, numbering):
+ return ''.join ([i.translations[self.language].texi_status (markup, numbering)
+ for i in self.masterdocument.includes
+ if self.language in i.translations])
+
+class IncludedTranslatedTelyDocument (TranslatedTelyDocument):
+ get_level = TelyDocument.get_level
+ def texi_status (self, markup, numbering=SectionNumber ()):
+ if self.title != 'Untitled':
+ return (markup.row (
+ (markup.cell ((
+ self.print_title (numbering)
+ + markup.newline ()
+ + '%d' % sum (self.masterdocument.word_count)),
+ [('title',filename)])
+ + self.texi_body (markup, numbering)),
+ [('align','left')])
+ + self.texi_translations (markup, numbering))
+ return ''
+
+class UntranslatedTelyDocument (TranslatedTelyDocument):
+ def __init__ (self, filename, masterdocument, parent_translation=None):
+ if filename[2] == '/':
+ self.language = filename[:2]
+ TranslatedTelyDocument.__init__ (self, filename, masterdocument, parent_translation)
- if self.level[1] == 0: # if self is a master document
- s += '</table>\n<p></p>\n'
- return s
+class IncludedUntranslatedTelyDocument (UntranslatedTelyDocument, IncludedTranslatedTelyDocument):
+ get_level = TelyDocument.get_level
class MasterTelyDocument (TelyDocument):
def __init__ (self,
TelyDocument.__init__ (self, filename)
self.size = len (self.contents)
self.word_count = tely_word_count (self.contents)
- translations = dict ([(lang, os.path.join (lang, filename))
- for lang in langdefs.LANGDICT])
- self.translations = \
- dict ([(lang,
- TranslatedTelyDocument (translations[lang],
- self, parent_translations.get (lang)))
- for lang in langdefs.LANGDICT
- if os.path.exists (translations[lang])])
- if self.translations:
- self.includes = [MasterTelyDocument (f, self.translations)
- for f in self.included_files]
- else:
- self.includes = []
+ self.translations = {}
+ self.includes = []
+ if not self.language or self.language == 'en':
+ languages = [x for x in parent_translations.keys () if x != 'en']
+ self.translations = dict ([x for x in
+ [(lang, self.translated_factory (os.path.join (lang, self.filename),
+ parent_translations.get (lang)))
+ for lang in languages]
+ if x[1]])
+ if self.translations:
+ self.includes = [IncludedMasterTelyDocument (f, self.translations)
+ for f in self.included_files]
+
+ def get_level (self):
+ return texi_level ['top']
+
+ def translated_factory (self, filename, parent):
+ if os.path.exists (filename):
+ return TranslatedTelyDocument (filename, self, parent)
+ return None
def update_word_counts (self, s):
s = update_word_count (s, self.filename, sum (self.word_count))
s = i.update_word_counts (s)
return s
- def html_status (self, numbering=SectionNumber ()):
- if self.title == 'Untitled' or not self.translations:
- return ''
- if self.level[1] == 0: # if self is a master document
- s = '''<table align="center" border="2">
- <tr align="center">
- <th>%s</th>''' % self.print_title (numbering)
- s += ''.join ([' <th>%s</th>\n' % l for l in self.translations])
- s += ' </tr>\n'
- s += ' <tr align="left">\n <td>Section titles<br>(%d)</td>\n' \
- % sum (self.word_count)
-
- else: # if self is an included file
- s = ' <tr align="left">\n <td>%s<br>(%d)</td>\n' \
- % (self.print_title (numbering), sum (self.word_count))
-
- s += ''.join ([t.short_html_status ()
- for t in self.translations.values ()])
- s += ' </tr>\n'
- s += ''.join ([i.html_status (numbering) for i in self.includes])
-
- if self.level[1] == 0: # if self is a master document
- s += '</table>\n<p></p>\n'
+ def texi_status (self, markup, numbering=SectionNumber ()):
+ return markup.table (
+ (markup.headrow (
+ (markup.headcell (self.print_title (numbering))
+ + ''.join ([markup.headcell (l) for l in sorted (self.translations.keys ())])),
+ [('align','center')])
+ + markup.row (
+ (markup.cell (('Section titles'
+ + markup.newline ()
+ + '(%d)' % sum (self.word_count)),
+ [('title',filename)])
+ + self.texi_body (markup, numbering)),
+ [('align','left')])
+ + self.texi_includes (markup, numbering)
+ )) + markup.paragraph ()
+
+ def texi_includes (self, markup, numbering):
+ return ''.join ([i.texi_status (markup, numbering) for i in self.includes])
+
+ def texi_body (self, markup, numbering):
+ return ''.join ([self.translations[k].short_texi_status (markup)
+ for k in sorted (self.translations.keys ())])
+
+ def text_status (self, markup, numbering=SectionNumber (), colspec=[48,12]):
+ s = (self.print_title (numbering) + ' ').ljust (colspec[0])
+ s += ''.join (['%s'.ljust (colspec[1]) % l
+ for l in sorted (self.translations.keys ())])
+ s += '\n'
+ s += ('Section titles (%d)' % \
+ sum (self.word_count)).ljust (colspec[0])
+ s += self.text_body (markup, numbering, colspec)
+ s += '\n'
return s
- def text_status (self, numbering=SectionNumber (), colspec=[48,12]):
- if self.title == 'Untitled' or not self.translations:
- return ''
-
- s = ''
- if self.level[1] == 0: # if self is a master document
- s += (self.print_title (numbering) + ' ').ljust (colspec[0])
- s += ''.join (['%s'.ljust (colspec[1]) % l
- for l in self.translations])
- s += '\n'
- s += ('Section titles (%d)' % \
- sum (self.word_count)).ljust (colspec[0])
-
- else:
- s = '%s (%d) ' \
- % (self.print_title (numbering), sum (self.word_count))
- s = s.ljust (colspec[0])
-
- s += ''.join ([t.text_status ().ljust(colspec[1])
- for t in self.translations.values ()])
- s += '\n\n'
- s += ''.join ([i.text_status (numbering) for i in self.includes])
-
- if self.level[1] == 0:
- s += '\n'
- return s
+ def text_body (self, markup, numbering, colspec):
+ return (''.join ([self.translations[k].text_status ().ljust(colspec[1])
+ for k in sorted (self.translations.keys ())])
+ + '\n\n'
+ + ''.join ([i.text_status (markup, numbering) for i in self.includes]))
+
+class IncludedMasterTelyDocument (MasterTelyDocument):
+ get_level = TelyDocument.get_level
+
+ def translated_factory (self, filename, parent):
+ if os.path.exists (filename):
+ return IncludedTranslatedTelyDocument (filename, self, parent)
+ return IncludedUntranslatedTelyDocument (filename, self, parent)
+
+ def texi_status (self, markup, numbering=SectionNumber ()):
+ if self.title != 'Untitled':
+ return (markup.row (
+ (markup.cell ((self.print_title (numbering)
+ + markup.newline ()
+ + '(%d)' % sum (self.word_count)),
+ [('title',filename)])
+ + self.texi_body (markup, numbering)),
+ [('align','left')])
+ + self.texi_includes (markup, numbering))
+ return ''
+
+ def text_status (self, markup, numbering=SectionNumber (), colspec=[48,12]):
+ if self.title != 'Untitled':
+ return (self.print_title (numbering)
+ + '(%d)' % sum (self.word_count)
+ + self.text_body (markup, numbering, colspec)
+ ).ljust (colspec[0])
+ return ''
update_category_word_counts_re = re.compile (r'(?ms)^-(\d+)-(.*?\n)\d+ *total')
counts_re = re.compile (r'(?m)^(\d+) ')
def update_category_word_counts_sub (m):
- return '-' + m.group (1) + '-' + m.group (2) + \
- str (sum ([int (c)
- for c in counts_re.findall (m.group (2))])).ljust (6) + \
- 'total'
+ return ('-' + m.group (1) + '-' + m.group (2)
+ + str (sum ([int (c)
+ for c in counts_re.findall (m.group (2))])).ljust (6)
+ + 'total')
+# urg
+# main () starts here-abouts
progress ("Reading documents...")
-tely_files = \
- buildlib.read_pipe ("find -maxdepth 2 -name '*.tely'")[0].splitlines ()
-tely_files.sort ()
+master_files = \
+ buildlib.read_pipe ("git ls-files | grep -E '[^/]*/?[^/]*[.](tely|texi)$'")[0].splitlines ()
+master_files.sort ()
master_docs = [MasterTelyDocument (os.path.normpath (filename))
- for filename in tely_files]
+ for filename in master_files]
master_docs = [doc for doc in master_docs if doc.translations]
-main_status_page = open ('translations.template.html.in').read ()
-
enabled_languages = [l for l in langdefs.LANGDICT
if langdefs.LANGDICT[l].enabled
and l != 'en']
-lang_status_pages = \
- dict ([(l, open (os.path.join (l, 'translations.template.html.in')). read ())
- for l in enabled_languages])
progress ("Generating status pages...")
date_time = buildlib.read_pipe ('LANG= date -u')[0]
-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)
-end_body_re = re.compile ('</body>', re.I)
-
-html_header = '''<html>
-<!-- This page is automatically generated by translation-status.py from
-translations.template.html.in; DO NOT EDIT !-->'''
-
-main_status_page = html_re.sub (html_header, main_status_page)
+# TEXI output sort of works
+# TODO: table border, td-titles :-)
+# markup = HTMLMarkup ()
+#sys.stderr.write ('''translations-status.py:713: warning: using markup = HTMLMarkup (): HTML only\n''')
+markup = TexiMarkup ()
+sys.stderr.write ('''translations-status.py:717: warning: using markup = TexiMarkup (): ugly HTML
+ output, questionable PDF and info output.
+ Consider using HTML-only markup = HTMLMarkup ()\n''')
-main_status_page = end_body_re.sub (main_status_html + '\n</body>',
- main_status_page)
+main_status_body = markup.paragraph (markup.emph (last_updated_string % date_time))
+main_status_body += '\n'.join ([doc.texi_status (markup) for doc in master_docs])
+main_status_page = markup.texi (main_status_body)
-open ('translations.html.in', 'w').write (main_status_page)
+open ('translations.itexi', '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 ()
+ updated = markup.paragraph (markup.emph (translation[l] (last_updated_string) % date_time))
+ texi_status = '\n'.join ([doc.translations[l].texi_status (markup)
for doc in master_docs
if l in doc.translations])
- lang_status_page = end_body_re.sub (html_status + '\n</body>',
- lang_status_page)
- open (os.path.join (l, 'translations.html.in'), 'w').write (lang_status_page)
+ lang_status_page = markup.texi (updated + texi_status)
+ open (os.path.join (l, 'translations.itexi'), 'w').write (lang_status_page)
main_status_txt = '''Documentation translations status
Generated %s
''' % date_time
-main_status_txt += '\n'.join ([doc.text_status () for doc in master_docs])
+main_status_txt += '\n'.join ([doc.text_status (markup) for doc in master_docs])
status_txt_file = 'out/translations-status.txt'
progress ("Writing %s..." % status_txt_file)
open (status_txt_file, 'w').write (main_status_txt)
-translation_instructions_file = 'devel/doc-translation-list.itexi'
+translation_instructions_file = 'contributor/doc-translation-list.itexi'
progress ("Updating %s..." % translation_instructions_file)
translation_instructions = open (translation_instructions_file).read ()