4 USAGE: cd Documentation && translations-status.py
8 <LANG>/translations.itexi
9 out/translations-status.txt
11 Update word counts in:
12 contributor/doc-translation-list.itexi
15 * using markup = TexiMarkup (), html tables (columns)
16 are evenly spaced and bit too wide. This can
18 @multitable @columnfractions 0 0 0 0 0 0 0 0,
19 but with that, PDF and info output get borked.
20 * in info and PDF, columns have too little separation
21 * using markup = HTMLMarkup (), we get nice
23 popups -- do we want that with texi output? -- how?
24 or possibly links to the git archive?
38 sys.stderr.write (str + '\n')
42 def error (str, update_status=1):
44 sys.stderr.write ('translations-status.py: %s\n' % str)
45 exit_code = max (exit_code, update_status)
47 progress ("translations-status.py")
51 # load gettext messages catalogs
52 translation = langdefs.translation
55 language_re = re.compile (r'^@documentlanguage (.+)', re.M)
56 comments_re = re.compile (r'^@ignore\n(.|\n)*?\n@end ignore$|@c .*?$', re.M)
57 space_re = re.compile (r'\s+', re.M)
58 lilypond_re = re.compile (r'@lilypond({.*?}|(.|\n)*?\n@end lilypond$)', re.M)
59 node_re = re.compile ('^@node .*?$', re.M)
60 title_re = re.compile ('^@(settitle|chapter|top|(?:sub){0,2}section|'
61 '(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?) (.*?)$', re.M)
62 include_re = re.compile ('^@include (.*?)$', re.M)
64 # allow multiple lines
65 translators_re = re.compile (r'^@c[ ]+[Tt]ranslators?[ ]*:[ ]*(.*?)$', re.M)
66 checkers_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Cc]heckers?[ ]*:[ ]*(.*?)$', re.M)
67 status_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Ss]tatus[ ]*:[ ]*(.*?)$', re.M)
68 post_gdp_re = re.compile ('post.GDP', re.I)
69 untranslated_node_str = '@untranslated'
70 skeleton_str = '-- SKELETON FILE --'
72 section_titles_string = _doc ('Section titles')
73 last_updated_string = _doc ('Last updated %s')
74 detailed_status_heads = [_doc ('Translators'), _doc ('Translation checkers'),
75 _doc ('Translated'), _doc ('Up to date'),
78 'not translated': {'color':'d0f0f8', 'short':_doc ('no'), 'abbr':'NT',
79 'long':_doc ('not translated')},
80 'partially translated': {'color':'dfef77',
81 'short':_doc ('partially (%(p)d %%)'),
83 'long':_doc ('partially translated (%(p)d %%)')},
84 'fully translated': {'color':'1fff1f', 'short':_doc ('yes'), 'abbr':'FT',
85 'long': _doc ('translated')},
86 'up to date': {'short':_doc ('yes'), 'long':_doc ('up to date'),
87 'abbr':'100%%', 'vague':_doc ('up to date')},
88 'outdated': {'short':_doc ('partially'), 'abbr':'%(p)d%%',
89 'vague':_doc ('partially up to date')},
90 'N/A': {'short':_doc ('N/A'), 'abbr':'N/A', 'color':'d587ff', 'vague':''},
91 'pre-GDP':_doc ('pre-GDP'),
92 'post-GDP':_doc ('post-GDP')
96 # (Unumbered/Numbered/Lettered, level)
98 'unnumbered': ('u', 1),
99 'unnumberedsec': ('u', 2),
100 'unnumberedsubsec': ('u', 3),
103 'subsection': ('n', 3),
104 'appendix': ('l', 1),
105 'appendixsec': ('l', 2),
108 appendix_number_trans = string.maketrans ('@ABCDEFGHIJKLMNOPQRSTUVWXY',
109 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
111 class SectionNumber (object):
113 self.__data = [[0,'u']]
115 def __increase_last_index (self):
116 type = self.__data[-1][1]
118 self.__data[-1][0] = \
119 self.__data[-1][0].translate (appendix_number_trans)
121 self.__data[-1][0] += 1
124 if self.__data[-1][1] == 'u':
126 return '.'.join ([str (i[0]) for i in self.__data if i[1] != 'u']) + ' '
128 def increase (self, (type, level)):
130 self.__data = [[0,'u']]
131 while level + 1 < len (self.__data):
133 if level + 1 > len (self.__data):
134 self.__data.append ([0, type])
136 self.__data[-1][0] = '@'
137 if type == self.__data[-1][1]:
138 self.__increase_last_index ()
140 self.__data[-1] = ([0, type])
142 self.__data[-1][0] = 'A'
144 self.__data[-1][0] = 1
145 return self.format ()
148 def percentage_color (percent):
151 c = [hex (int (3 * p * b + (1 - 3 * p) * a))[2:]
152 for (a, b) in [(0xff, 0xff), (0x5c, 0xa6), (0x5c, 0x4c)]]
154 c = [hex (int ((3 * p - 1) * b + (2 - 3 * p) * a))[2:]
155 for (a, b) in [(0xff, 0xff), (0xa6, 0xff), (0x4c, 0x3d)]]
157 c = [hex (int ((3 * p - 2) * b + 3 * (1 - p) * a))[2:]
158 for (a, b) in [(0xff, 0x1f), (0xff, 0xff), (0x3d, 0x1f)]]
162 def update_word_count (text, filename, word_count):
163 return re.sub (r'(?m)^(\d+) *' + filename,
164 str (word_count).ljust (6) + filename,
167 po_msgid_re = re.compile (r'^msgid "(.*?)"(?:\n"(.*?)")*', re.M)
169 def po_word_count (po_content):
170 s = ' '.join ([''.join (t) for t in po_msgid_re.findall (po_content)])
171 return len (space_re.split (s))
173 sgml_tag_re = re.compile (r'<.*?>', re.S)
175 def sgml_word_count (sgml_doc):
176 s = sgml_tag_re.sub ('', sgml_doc)
177 return len (space_re.split (s))
179 def tely_word_count (tely_doc):
181 Calculate word count of a Texinfo document node by node.
183 Take string tely_doc as an argument.
184 Return a list of integers.
186 Texinfo comments and @lilypond blocks are not included in word counts.
188 tely_doc = comments_re.sub ('', tely_doc)
189 tely_doc = lilypond_re.sub ('', tely_doc)
190 nodes = node_re.split (tely_doc)
191 return [len (space_re.split (n)) for n in nodes]
193 class HTMLMarkup (object):
194 texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*-
195 @c This file was generated by translation-status.py -- DO NOT EDIT!
197 Translation of GIT committish: 0
203 def texi (self, string):
204 return (self.texi_header
207 Translation status currently only available in HTML.
212 def entity (self, name, string='', attributes=[]):
213 attr_list = ''.join ([' %s="%s"' % x for x in attributes])
214 return '<%(name)s%(attr_list)s>%(string)s</%(name)s>' % locals ()
215 def paragraph (self, string=''):
216 return self.entity ('p', string)
217 def table (self, string):
218 return self.entity ('table', string, [('align', 'center'), ('border', '2')])
219 def row (self, string, attributes=[]):
220 return self.entity ('tr', string, attributes)
222 def headcell (self, string, attributes=[]):
223 return self.entity ('th', string, attributes)
224 def cell (self, string='', attributes=[]):
225 return self.entity ('td', string, attributes)
226 def newline (self, attributes=[]):
227 return self.entity ('br', '', attributes)[:-5]
228 def span (self, string, attributes=[]):
229 return self.entity ('span', string, attributes)
230 def small (self, string, attributes=[]):
231 return self.entity ('small', string, attributes)
232 def emph (self, string, attributes=[]):
233 return self.entity ('em', string, attributes)
235 class TexiMarkup (HTMLMarkup):
236 def texi (self, string):
237 return (self.texi_header
239 <style type="text/css"><!--
240 th { border: 1px solid black; text-align: center; }
241 td { border: 1px solid black; text-align: center; }
244 + self.columnfraction_disaster (self.itemtab_disaster (string))
246 def itemtab_disaster (self, string):
247 return string.replace ('''item \n@tab ''', '''item
249 def columnfraction_disaster (self, string):
251 # nice trick for html-only
252 return string.replace ('@multitable', '@multitable @columnfractions 0 0 0 0 0 0 0 0 0 0')
253 tables = re.findall ('(?s)(@multitable)(.*?)(@item)', string)
255 columns = len (re.findall ('(?s)(\n@tab)', t[1])) + 1
256 columnfractions = '@columnfractions ' + (' ' + str (1.0/columns)) * columns
257 string = string.replace ('@multitable\n',
258 '@multitable %(columnfractions)s\n' % locals (), 1)
260 def entity (self, name, string='', attributes=[]):
264 @end %(name)s''' % locals ()
265 def paragraph (self, string=''):
267 %(string)s''' % locals ()
268 def table (self, string):
269 # Ugh, makeinfo is fine without @columnfractions
270 # but texi2html 1.82 barfs: `empty multicolumn'
271 return (self.entity ('multitable', string))
272 def headrow (self, string, attributes=[]):
274 @headitem ''' + string
275 def row (self, string, attributes=[]):
278 def cell (self, string='', attributes=[]):
286 def html (self, string):
287 return self.entity ('ifhtml', self.entity ('html', string))
288 def nothtml (self, string):
289 return self.entity ('ifnothtml', string)
290 def span (self, string, attributes=[]):
291 return (self.html (HTMLMarkup ().span (string, attributes))
292 + self.nothtml (string))
293 def small (self, string, attributes=[]):
294 return (self.html (HTMLMarkup ().small (string, attributes))
295 + self.nothtml (string))
296 def command (self, name, string):
297 return '@%(name)s{%(string)s}' % locals ()
298 def emph (self, string, attributes=[]):
299 return self.command ('emph', string)
301 class TelyDocument (object):
302 def __init__ (self, filename):
303 self.filename = filename
304 self.contents = 'GIT committish: 0'
305 if os.path.exists (filename):
306 self.contents = open (filename).read ()
307 ## record title and sectionning level of first Texinfo section
308 self.sectioning = 'unnumbered'
309 self.title = 'Untitled'
310 m = title_re.search (self.contents)
312 self.sectioning = m.group (1)
313 self.title = m.group (2)
315 if not hasattr (self, 'language'):
317 m = language_re.search (self.contents)
319 self.language = m.group (1)
321 dir = os.path.dirname (filename).split ('/')[0]
326 included_files = [dir + t
327 for t in include_re.findall (self.contents)]
328 self.included_files = [p for p in included_files if os.path.exists (p)]
330 def get_level (self):
331 return texi_level [self.sectioning]
333 def print_title (self, section_number):
334 if not hasattr (self, 'level'):
335 self.level = self.get_level ()
336 return section_number.increase (self.level) + self.title
339 class TranslatedTelyDocument (TelyDocument):
340 def __init__ (self, filename, masterdocument, parent_translation=None):
341 TelyDocument.__init__ (self, filename)
342 self.masterdocument = masterdocument
343 if not hasattr (self, 'language'):
345 if not self.language and parent_translation:
346 self.language = parent_translation.__dict__.get ('language', '')
347 if self.language == 'en':
348 print filename + ': language en specified: set @documentlanguage', self.filename[:2]
350 if not self.language and filename[2] == '/':
351 print filename + ': no language specified: add @documentlanguage', self.filename[:2]
352 self.language = filename[:2]
354 self.translation = translation[self.language]
356 self.translation = lambda x: x
357 self.title = self.translation (self.title)
359 ## record authoring information
360 self.translators = ['']
361 if parent_translation:
362 self.translators = parent_translation.__dict__.get ('translators', [''])
363 m = translators_re.findall (self.contents)
365 self.translators = [n.strip () for n in
366 reduce (operator.add, [n.split (',') for n in m])]
367 if self.language != self.filename[:2]:
368 print 'Barf:', self.filename
370 if (not isinstance (self, UntranslatedTelyDocument)
371 and (not self.translators or not self.translators[0])
372 and not 'macros.itexi' in self.filename):
373 error (self.filename + ''': error: no translator name found
374 please specify one ore more lines in the master file
375 @c Translator: FirstName LastName[, FirstName LastName]..''')
377 m = checkers_re.findall (self.contents)
379 self.checkers = [n.strip () for n in
380 reduce (operator.add, [n.split (',') for n in m])]
381 if not self.checkers and isinstance (parent_translation, TranslatedTelyDocument):
382 self.checkers = parent_translation.checkers
384 ## check whether translation is pre- or post-GDP
385 m = status_re.search (self.contents)
387 self.post_gdp = bool (post_gdp_re.search (m.group (1)))
389 self.post_gdp = False
391 ## record which parts (nodes) of the file are actually translated
392 self.partially_translated = not skeleton_str in self.contents
393 nodes = node_re.split (self.contents)
394 self.translated_nodes = [not untranslated_node_str in n for n in nodes]
396 ## calculate translation percentage
397 master_total_word_count = sum (masterdocument.word_count)
398 translation_word_count = \
399 sum ([masterdocument.word_count[k] * self.translated_nodes[k]
400 for k in range (min (len (masterdocument.word_count),
401 len (self.translated_nodes)))])
402 self.translation_percentage = \
403 100 * translation_word_count / master_total_word_count
405 ## calculate how much the file is outdated
406 (diff_string, git_error) = \
407 buildlib.check_translated_doc (masterdocument.filename, self.filename, self.contents)
409 sys.stderr.write ('warning: %s: %s' % (self.filename, git_error))
410 self.uptodate_percentage = None
412 diff = diff_string.splitlines ()
413 insertions = sum ([len (l) - 1 for l in diff
414 if l.startswith ('+')
415 and not l.startswith ('+++')])
416 deletions = sum ([len (l) - 1 for l in diff
417 if l.startswith ('-')
418 and not l.startswith ('---')])
419 outdateness_percentage = 50.0 * (deletions + insertions) / \
420 (masterdocument.size + 0.5 * (deletions - insertions))
421 self.uptodate_percentage = 100 - int (outdateness_percentage)
422 if self.uptodate_percentage > 100:
424 progress ("%s: strange uptodateness percentage %d %%, \
425 setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
426 self.uptodate_percentage = alternative
427 elif self.uptodate_percentage < 1:
429 progress ("%s: strange uptodateness percentage %d %%, \
430 setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
431 self.uptodate_percentage = alternative
433 def get_level (self):
434 return texi_level ['top']
436 def completeness (self, formats=['long'], translated=False):
438 translation = self.translation
440 translation = lambda x: x
442 if isinstance (formats, str):
444 p = self.translation_percentage
446 status = 'not translated'
448 status = 'fully translated'
450 status = 'partially translated'
451 return dict ([(f, translation (format_table[status][f]) % locals())
454 def uptodateness (self, formats=['long'], translated=False):
456 translation = self.translation
458 translation = lambda x: x
460 if isinstance (formats, str):
462 p = self.uptodate_percentage
466 status = 'up to date'
471 if f == 'color' and p != None:
472 l['color'] = percentage_color (p)
474 l[f] = translation (format_table[status][f]) % locals ()
477 def gdp_status (self):
479 return self.translation (format_table['post-GDP'])
481 return self.translation (format_table['pre-GDP'])
483 def short_texi_status (self, markup):
485 if self.partially_translated:
486 s += markup.newline ().join (self.translators + [''])
488 s += markup.newline ().join ([markup.small (x) for x in self.checkers + ['']])
489 c = self.completeness (['color', 'long'])
490 s += markup.span ('%(long)s' % c, [('style', 'background-color: #%(color)s' % c)])
491 s += markup.newline ()
492 if self.partially_translated:
493 u = self.uptodateness (['vague', 'color'])
494 s += markup.span ('%(vague)s' % u, [('style', 'background-color: #%(color)s' % u)])
495 return markup.cell (s, [('title', filename)])
497 def text_status (self):
498 s = self.completeness ('abbr')['abbr'] + ' '
499 if self.partially_translated:
500 s += self.uptodateness ('abbr')['abbr'] + ' '
503 def texi_status (self, markup, numbering=SectionNumber ()):
504 return (markup.table (
506 (markup.headcell (self.print_title (numbering))
507 + ''.join ([markup.headcell (self.translation (h))
508 for h in detailed_status_heads])),
509 [('align', 'center')])
511 (markup.cell ((self.translation (section_titles_string)
513 + '%d' % sum (self.masterdocument.word_count)),
514 [('title',filename)])
515 + self.texi_body (markup, numbering)),
517 + self.texi_translations (markup, numbering))
518 ) + markup.paragraph ()
520 def texi_body (self, markup, numbering):
521 return (self.texi_translators (markup)
522 + self.texi_completeness (markup)
523 + self.texi_uptodateness (markup)
524 + self.texi_gdp (markup))
526 def texi_translators (self, markup):
527 if self.partially_translated:
528 return (markup.cell (markup.newline ().join (self.translators))
529 + markup.cell (markup.newline ().join (self.checkers)))
530 return markup.cell () + markup.cell ()
532 def texi_completeness (self, markup):
533 c = self.completeness (['color', 'short'], translated=True)
534 return markup.cell (markup.span (c['short'],
535 [('style', 'background-color: #' + c['color'])]))
537 def texi_uptodateness (self, markup):
538 if self.partially_translated:
539 u = self.uptodateness (['short', 'color'], translated=True)
540 return markup.cell (markup.span (u['short'],
541 [('style', 'background-color: #' + u['color'])]))
542 return markup.cell ()
544 def texi_gdp (self, markup):
545 return markup.cell (self.gdp_status ())
547 def texi_translations (self, markup, numbering):
548 return ''.join ([i.translations[self.language].texi_status (markup, numbering)
549 for i in self.masterdocument.includes
550 if self.language in i.translations])
552 class IncludedTranslatedTelyDocument (TranslatedTelyDocument):
553 get_level = TelyDocument.get_level
554 def texi_status (self, markup, numbering=SectionNumber ()):
555 if self.title != 'Untitled':
558 self.print_title (numbering)
560 + '%d' % sum (self.masterdocument.word_count)),
561 [('title',filename)])
562 + self.texi_body (markup, numbering)),
564 + self.texi_translations (markup, numbering))
567 class UntranslatedTelyDocument (TranslatedTelyDocument):
568 def __init__ (self, filename, masterdocument, parent_translation=None):
569 if filename[2] == '/':
570 self.language = filename[:2]
571 TranslatedTelyDocument.__init__ (self, filename, masterdocument, parent_translation)
573 class IncludedUntranslatedTelyDocument (UntranslatedTelyDocument, IncludedTranslatedTelyDocument):
574 get_level = TelyDocument.get_level
576 class MasterTelyDocument (TelyDocument):
579 parent_translations=dict ([(lang, None)
580 for lang in langdefs.LANGDICT])):
581 TelyDocument.__init__ (self, filename)
582 self.size = len (self.contents)
583 self.word_count = tely_word_count (self.contents)
584 self.translations = {}
586 if not self.language or self.language == 'en':
587 languages = [x for x in parent_translations.keys () if x != 'en']
588 self.translations = dict ([x for x in
589 [(lang, self.translated_factory (os.path.join (lang, self.filename),
590 parent_translations.get (lang)))
591 for lang in languages]
593 if self.translations:
594 self.includes = [IncludedMasterTelyDocument (f, self.translations)
595 for f in self.included_files]
597 def get_level (self):
598 return texi_level ['top']
600 def translated_factory (self, filename, parent):
601 if os.path.exists (filename):
602 return TranslatedTelyDocument (filename, self, parent)
605 def update_word_counts (self, s):
606 s = update_word_count (s, self.filename, sum (self.word_count))
607 for i in self.includes:
608 s = i.update_word_counts (s)
611 def texi_status (self, markup, numbering=SectionNumber ()):
612 return markup.table (
614 (markup.headcell (self.print_title (numbering))
615 + ''.join ([markup.headcell (l) for l in sorted (self.translations.keys ())])),
616 [('align','center')])
618 (markup.cell (('Section titles'
620 + '(%d)' % sum (self.word_count)),
621 [('title',filename)])
622 + self.texi_body (markup, numbering)),
624 + self.texi_includes (markup, numbering)
625 )) + markup.paragraph ()
627 def texi_includes (self, markup, numbering):
628 return ''.join ([i.texi_status (markup, numbering) for i in self.includes])
630 def texi_body (self, markup, numbering):
631 return ''.join ([self.translations[k].short_texi_status (markup)
632 for k in sorted (self.translations.keys ())])
634 def text_status (self, markup, numbering=SectionNumber (), colspec=[48,12]):
635 s = (self.print_title (numbering) + ' ').ljust (colspec[0])
636 s += ''.join (['%s'.ljust (colspec[1]) % l
637 for l in sorted (self.translations.keys ())])
639 s += ('Section titles (%d)' % \
640 sum (self.word_count)).ljust (colspec[0])
641 s += self.text_body (markup, numbering, colspec)
645 def text_body (self, markup, numbering, colspec):
646 return (''.join ([self.translations[k].text_status ().ljust(colspec[1])
647 for k in sorted (self.translations.keys ())])
649 + ''.join ([i.text_status (markup, numbering) for i in self.includes]))
651 class IncludedMasterTelyDocument (MasterTelyDocument):
652 get_level = TelyDocument.get_level
654 def translated_factory (self, filename, parent):
655 if os.path.exists (filename):
656 return IncludedTranslatedTelyDocument (filename, self, parent)
657 return IncludedUntranslatedTelyDocument (filename, self, parent)
659 def texi_status (self, markup, numbering=SectionNumber ()):
660 if self.title != 'Untitled':
662 (markup.cell ((self.print_title (numbering)
664 + '(%d)' % sum (self.word_count)),
665 [('title',filename)])
666 + self.texi_body (markup, numbering)),
668 + self.texi_includes (markup, numbering))
671 def text_status (self, markup, numbering=SectionNumber (), colspec=[48,12]):
672 if self.title != 'Untitled':
673 return (self.print_title (numbering)
674 + '(%d)' % sum (self.word_count)
675 + self.text_body (markup, numbering, colspec)
680 update_category_word_counts_re = re.compile (r'(?ms)^-(\d+)-(.*?\n)\d+ *total')
682 counts_re = re.compile (r'(?m)^(\d+) ')
684 def update_category_word_counts_sub (m):
685 return ('-' + m.group (1) + '-' + m.group (2)
687 for c in counts_re.findall (m.group (2))])).ljust (6)
691 # main () starts here-abouts
693 progress ("Reading documents...")
696 buildlib.read_pipe ("git ls-files | grep -E '[^/]*/?[^/]*[.](tely|texi)$'")[0].splitlines ()
698 master_docs = [MasterTelyDocument (os.path.normpath (filename))
699 for filename in master_files]
700 master_docs = [doc for doc in master_docs if doc.translations]
702 enabled_languages = [l for l in langdefs.LANGDICT
703 if langdefs.LANGDICT[l].enabled
706 progress ("Generating status pages...")
708 date_time = buildlib.read_pipe ('LANG= date -u')[0]
710 # TEXI output sort of works
711 # TODO: table border, td-titles :-)
712 # markup = HTMLMarkup ()
713 #sys.stderr.write ('''translations-status.py:713: warning: using markup = HTMLMarkup (): HTML only\n''')
714 markup = TexiMarkup ()
715 sys.stderr.write ('''translations-status.py:717: warning: using markup = TexiMarkup (): ugly HTML
716 output, questionable PDF and info output.
717 Consider using HTML-only markup = HTMLMarkup ()\n''')
719 main_status_body = markup.paragraph (markup.emph (last_updated_string % date_time))
720 main_status_body += '\n'.join ([doc.texi_status (markup) for doc in master_docs])
721 main_status_page = markup.texi (main_status_body)
723 open ('translations.itexi', 'w').write (main_status_page)
725 for l in enabled_languages:
726 date_time = buildlib.read_pipe ('LANG=%s date -u' % l)[0]
727 updated = markup.paragraph (markup.emph (translation[l] (last_updated_string) % date_time))
728 texi_status = '\n'.join ([doc.translations[l].texi_status (markup)
729 for doc in master_docs
730 if l in doc.translations])
731 lang_status_page = markup.texi (updated + texi_status)
732 open (os.path.join (l, 'translations.itexi'), 'w').write (lang_status_page)
734 main_status_txt = '''Documentation translations status
737 FT = fully translated
741 main_status_txt += '\n'.join ([doc.text_status (markup) for doc in master_docs])
743 status_txt_file = 'out/translations-status.txt'
744 progress ("Writing %s..." % status_txt_file)
745 open (status_txt_file, 'w').write (main_status_txt)
747 translation_instructions_file = 'contributor/doc-translation-list.itexi'
748 progress ("Updating %s..." % translation_instructions_file)
749 translation_instructions = open (translation_instructions_file).read ()
751 for doc in master_docs:
752 translation_instructions = doc.update_word_counts (translation_instructions)
754 for html_file in re.findall (r'(?m)^\d+ *(\S+?\.html\S*?)(?: |$)',
755 translation_instructions):
756 word_count = sgml_word_count (open (html_file).read ())
757 translation_instructions = update_word_count (translation_instructions,
761 for po_file in re.findall (r'(?m)^\d+ *(\S+?\.po\S*?)(?: |$)',
762 translation_instructions):
763 word_count = po_word_count (open (po_file).read ())
764 translation_instructions = update_word_count (translation_instructions,
768 translation_instructions = \
769 update_category_word_counts_re.sub (update_category_word_counts_sub,
770 translation_instructions)
772 open (translation_instructions_file, 'w').write (translation_instructions)