]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/translations-status.py
translations-status.py: Remove iffy setting of level from constructors.
[lilypond.git] / scripts / auxiliar / translations-status.py
1 #!/usr/bin/env python
2
3 '''
4 USAGE: cd Documentation && translations-status.py
5
6   Write:
7     translations.itexi
8     <LANG>/translations.itexi
9     out/translations-status.txt
10
11   Update word counts in:
12     contributor/doc-translation-list.itexi
13 '''
14
15 import sys
16 import re
17 import string
18 import operator
19 import os
20 #
21 import langdefs
22 import buildlib
23
24 def progress (str):
25     sys.stderr.write (str + '\n')
26
27 exit_code = 0
28
29 def error (str, update_status=1):
30     global exit_code
31     sys.stderr.write ('translations-status.py: %s\n' % str)
32     exit_code = max (exit_code, update_status)
33
34 progress ("translations-status.py")
35
36 _doc = lambda s: s
37
38 # load gettext messages catalogs
39 translation = langdefs.translation
40
41
42 language_re = re.compile (r'^@documentlanguage (.+)', re.M)
43 comments_re = re.compile (r'^@ignore\n(.|\n)*?\n@end ignore$|@c .*?$', re.M)
44 space_re = re.compile (r'\s+', re.M)
45 lilypond_re = re.compile (r'@lilypond({.*?}|(.|\n)*?\n@end lilypond$)', re.M)
46 node_re = re.compile ('^@node .*?$', re.M)
47 title_re = re.compile ('^@(settitle|chapter|top|(?:sub){0,2}section|'
48                            '(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?) (.*?)$', re.M)
49 include_re = re.compile ('^@include (.*?)$', re.M)
50
51 # allow multiple lines
52 translators_re = re.compile (r'^@c[ ]+[Tt]ranslators?[ ]*:[ ]*(.*?)$', re.M)
53 checkers_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Cc]heckers?[ ]*:[ ]*(.*?)$', re.M)
54 status_re = re.compile (r'^@c[ ]+[Tt]ranslation[ ]*[Ss]tatus[ ]*:[ ]*(.*?)$', re.M)
55 post_gdp_re = re.compile ('post.GDP', re.I)
56 untranslated_node_str = '@untranslated'
57 skeleton_str = '-- SKELETON FILE --'
58
59 section_titles_string = _doc ('Section titles')
60 last_updated_string = _doc (' <p><i>Last updated %s</i></p>\n')
61 detailed_status_heads = [_doc ('Translators'), _doc ('Translation checkers'),
62                          _doc ('Translated'), _doc ('Up to date'),
63                          _doc ('Other info')]
64 format_table = {
65     'not translated': {'color':'d0f0f8', 'short':_doc ('no'), 'abbr':'NT',
66                        'long':_doc ('not translated')},
67     'partially translated': {'color':'dfef77',
68                              'short':_doc ('partially (%(p)d %%)'),
69                              'abbr':'%(p)d%%',
70                              'long':_doc ('partially translated (%(p)d %%)')},
71     'fully translated': {'color':'1fff1f', 'short':_doc ('yes'), 'abbr':'FT',
72                          'long': _doc ('translated')},
73     'up to date': {'short':_doc ('yes'), 'long':_doc ('up to date'),
74                    'abbr':'100%%', 'vague':_doc ('up to date')},
75     'outdated': {'short':_doc ('partially'), 'abbr':'%(p)d%%',
76                  'vague':_doc ('partially up to date')},
77     'N/A': {'short':_doc ('N/A'), 'abbr':'N/A', 'color':'d587ff', 'vague':''},
78     'pre-GDP':_doc ('pre-GDP'),
79     'post-GDP':_doc ('post-GDP')
80 }
81
82 texi_level = {
83 # (Unumbered/Numbered/Lettered, level)
84     'top': ('u', 0),
85     'unnumbered': ('u', 1),
86     'unnumberedsec': ('u', 2),
87     'unnumberedsubsec': ('u', 3),
88     'chapter': ('n', 1),
89     'section': ('n', 2),
90     'subsection': ('n', 3),
91     'appendix': ('l', 1),
92     'appendixsec': ('l', 2),
93 }
94
95 appendix_number_trans = string.maketrans ('@ABCDEFGHIJKLMNOPQRSTUVWXY',
96                                           'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
97
98 class SectionNumber (object):
99     def __init__ (self):
100         self.__data = [[0,'u']]
101
102     def __increase_last_index (self):
103         type = self.__data[-1][1]
104         if type == 'l':
105             self.__data[-1][0] = \
106                 self.__data[-1][0].translate (appendix_number_trans)
107         elif type == 'n':
108             self.__data[-1][0] += 1
109
110     def format (self):
111         if self.__data[-1][1] == 'u':
112             return ''
113         return '.'.join ([str (i[0]) for i in self.__data if i[1] != 'u']) + ' '
114
115     def increase (self, (type, level)):
116         if level == 0:
117             self.__data = [[0,'u']]
118         while level + 1 < len (self.__data):
119             del self.__data[-1]
120         if level + 1 > len (self.__data):
121             self.__data.append ([0, type])
122             if type == 'l':
123                 self.__data[-1][0] = '@'
124         if type == self.__data[-1][1]:
125             self.__increase_last_index ()
126         else:
127             self.__data[-1] = ([0, type])
128             if type == 'l':
129                 self.__data[-1][0] = 'A'
130             elif type == 'n':
131                 self.__data[-1][0] = 1
132         return self.format ()
133
134
135 def percentage_color (percent):
136     p = percent / 100.0
137     if p < 0.33:
138         c = [hex (int (3 * p * b + (1 - 3 * p) * a))[2:]
139              for (a, b) in [(0xff, 0xff), (0x5c, 0xa6), (0x5c, 0x4c)]]
140     elif p < 0.67:
141         c = [hex (int ((3 * p - 1) * b + (2 - 3 * p) * a))[2:]
142              for (a, b) in [(0xff, 0xff), (0xa6, 0xff), (0x4c, 0x3d)]]
143     else:
144         c = [hex (int ((3 * p - 2) * b + 3 * (1 - p) * a))[2:]
145              for (a, b) in [(0xff, 0x1f), (0xff, 0xff), (0x3d, 0x1f)]]
146     return ''.join (c)
147
148
149 def update_word_count (text, filename, word_count):
150     return re.sub (r'(?m)^(\d+) *' + filename,
151                    str (word_count).ljust (6) + filename,
152                    text)
153
154 po_msgid_re = re.compile (r'^msgid "(.*?)"(?:\n"(.*?)")*', re.M)
155
156 def po_word_count (po_content):
157     s = ' '.join ([''.join (t) for t in po_msgid_re.findall (po_content)])
158     return len (space_re.split (s))
159
160 sgml_tag_re = re.compile (r'<.*?>', re.S)
161
162 def sgml_word_count (sgml_doc):
163     s = sgml_tag_re.sub ('', sgml_doc)
164     return len (space_re.split (s))
165
166 def tely_word_count (tely_doc):
167     '''
168     Calculate word count of a Texinfo document node by node.
169
170     Take string tely_doc as an argument.
171     Return a list of integers.
172
173     Texinfo comments and @lilypond blocks are not included in word counts.
174     '''
175     tely_doc = comments_re.sub ('', tely_doc)
176     tely_doc = lilypond_re.sub ('', tely_doc)
177     nodes = node_re.split (tely_doc)
178     return [len (space_re.split (n)) for n in nodes]
179
180
181 class TelyDocument (object):
182     def __init__ (self, filename):
183         self.filename = filename
184         self.contents = 'GIT committish: 0'
185         if os.path.exists (filename):
186             self.contents = open (filename).read ()
187         self.top = os.path.splitext (filename)[1] in ['.tely', '.texi']
188         ## record title and sectionning level of first Texinfo section
189         self.sectioning = 'unnumbered'
190         self.title = 'Untitled'
191         m = title_re.search (self.contents)
192         if m:
193             self.sectioning = m.group (1)
194             self.title = m.group (2)
195
196         if not hasattr (self, 'language'):
197             self.language = ''
198         m = language_re.search (self.contents)
199         if m:
200             self.language = m.group (1)
201
202         dir = os.path.dirname (filename).split ('/')[0]
203         if len (dir) == 2:
204             dir += '/'
205         else:
206             dir = ''
207         included_files = [dir + t
208                           for t in include_re.findall (self.contents)]
209         self.included_files = [p for p in included_files if os.path.exists (p)]
210
211     def get_level (self):
212         return texi_level [self.sectioning]
213
214     def print_title (self, section_number):
215         if not hasattr (self, 'level'):
216             self.level = self.get_level ()
217         return section_number.increase (self.level) + self.title
218
219
220 class TranslatedTelyDocument (TelyDocument):
221     def __init__ (self, filename, masterdocument, parent_translation=None):
222         TelyDocument.__init__ (self, filename)
223         self.masterdocument = masterdocument
224         if not hasattr (self, 'language'):
225             self.language = ''
226         if not self.language and parent_translation:
227             self.language = parent_translation.__dict__.get ('language', '')
228         if self.language == 'en':
229             print filename + ': language en specified: set @documentlanguage', self.filename[:2]
230             self.language = ''
231         if not self.language and filename[2] == '/':
232             print filename + ': no language specified: add @documentlanguage', self.filename[:2]
233             self.language = filename[:2]
234         if self.language:
235             self.translation = translation[self.language]
236         else:
237             self.translation = lambda x: x
238         self.title = self.translation (self.title)
239
240         ## record authoring information
241         self.translators = ['']
242         if parent_translation:
243             self.translators = parent_translation.__dict__.get ('translators', [''])
244         m = translators_re.findall (self.contents)
245         if m:
246             self.translators = [n.strip () for n in
247                                 reduce (operator.add, [n.split (',') for n in m])]
248         if self.language != self.filename[:2]:
249             print 'Barf:', self.filename
250             barf
251         if (not isinstance (self, UntranslatedTelyDocument)
252             and (not self.translators or not self.translators[0])
253             and not 'macros.itexi' in self.filename):
254             error (self.filename + ''': error: no translator name found
255 please specify one ore more lines in the master file
256 @c Translator: FirstName LastName[, FirstName LastName]..''')
257         self.checkers = []
258         m = checkers_re.findall (self.contents)
259         if m:
260             self.checkers = [n.strip () for n in
261                              reduce (operator.add, [n.split (',') for n in m])]
262         if not self.checkers and isinstance (parent_translation, TranslatedTelyDocument):
263             self.checkers = parent_translation.checkers
264
265         ## check whether translation is pre- or post-GDP
266         m = status_re.search (self.contents)
267         if m:
268             self.post_gdp = bool (post_gdp_re.search (m.group (1)))
269         else:
270             self.post_gdp = False
271
272         ## record which parts (nodes) of the file are actually translated
273         self.partially_translated = not skeleton_str in self.contents
274         nodes = node_re.split (self.contents)
275         self.translated_nodes = [not untranslated_node_str in n for n in nodes]
276
277         ## calculate translation percentage
278         master_total_word_count = sum (masterdocument.word_count)
279         translation_word_count = \
280             sum ([masterdocument.word_count[k] * self.translated_nodes[k]
281                   for k in range (min (len (masterdocument.word_count),
282                                        len (self.translated_nodes)))])
283         self.translation_percentage = \
284             100 * translation_word_count / master_total_word_count
285
286         ## calculate how much the file is outdated
287         (diff_string, git_error) = \
288             buildlib.check_translated_doc (masterdocument.filename, self.filename, self.contents)
289         if git_error:
290             sys.stderr.write ('warning: %s: %s' % (self.filename, git_error))
291             self.uptodate_percentage = None
292         else:
293             diff = diff_string.splitlines ()
294             insertions = sum ([len (l) - 1 for l in diff
295                                if l.startswith ('+')
296                                and not l.startswith ('+++')])
297             deletions = sum ([len (l) - 1 for l in diff
298                               if l.startswith ('-')
299                               and not l.startswith ('---')])
300             outdateness_percentage = 50.0 * (deletions + insertions) / \
301                 (masterdocument.size + 0.5 * (deletions - insertions))
302             self.uptodate_percentage = 100 - int (outdateness_percentage)
303             if self.uptodate_percentage > 100:
304                 alternative = 50
305                 progress ("%s: strange uptodateness percentage %d %%, \
306 setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
307                 self.uptodate_percentage = alternative
308             elif self.uptodate_percentage < 1:
309                 alternative = 1
310                 progress ("%s: strange uptodateness percentage %d %%, \
311 setting to %d %%" % (self.filename, self.uptodate_percentage, alternative))
312                 self.uptodate_percentage = alternative
313
314     def get_level (self):
315         return texi_level ['top']
316
317     def completeness (self, formats=['long'], translated=False):
318         if translated:
319             translation = self.translation
320         else:
321             translation = lambda x: x
322
323         if isinstance (formats, str):
324             formats = [formats]
325         p = self.translation_percentage
326         if p == 0:
327             status = 'not translated'
328         elif p == 100:
329             status = 'fully translated'
330         else:
331             status = 'partially translated'
332         return dict ([(f, translation (format_table[status][f]) % locals())
333                       for f in formats])
334
335     def uptodateness (self, formats=['long'], translated=False):
336         if translated:
337             translation = self.translation
338         else:
339             translation = lambda x: x
340
341         if isinstance (formats, str):
342             formats = [formats]
343         p = self.uptodate_percentage
344         if p == None:
345             status = 'N/A'
346         elif p == 100:
347             status = 'up to date'
348         else:
349             status = 'outdated'
350         l = {}
351         for f in formats:
352             if f == 'color' and p != None:
353                 l['color'] = percentage_color (p)
354             else:
355                 l[f] = translation (format_table[status][f]) % locals ()
356         return l
357
358     def gdp_status (self):
359         if self.post_gdp:
360             return self.translation (format_table['post-GDP'])
361         else:
362             return self.translation (format_table['pre-GDP'])
363
364     def short_texi_status (self):
365         s = '  <td title="%(filename)s">' % self.__dict__
366         if self.partially_translated:
367             s += '<br>\n   '.join (self.translators) + '<br>\n'
368             if self.checkers:
369                 s += '   <small>' + \
370                     '<br>\n   '.join (self.checkers) + '</small><br>\n'
371
372         c = self.completeness (['color', 'long'])
373         s += '   <span style="background-color: #%(color)s">\
374 %(long)s</span><br>\n' % c
375
376         if self.partially_translated:
377             u = self.uptodateness (['vague', 'color'])
378             s += '   <span style="background-color: #%(color)s">\
379 %(vague)s</span><br>\n' % u
380
381         s += '  </td>\n'
382         return s
383
384     def text_status (self):
385         s = self.completeness ('abbr')['abbr'] + ' '
386
387         if self.partially_translated:
388             s += self.uptodateness ('abbr')['abbr'] + ' '
389         return s
390
391     def texi_status (self, numbering=SectionNumber ()):
392         if self.title == 'Untitled':
393             return ''
394
395         if self.top:
396             s = '''<table align="center" border="2">
397  <tr align="center">
398   <th>%s</th>''' % self.print_title (numbering)
399             s += ''.join (['  <th>%s</th>\n' % self.translation (h)
400                            for h in detailed_status_heads])
401             s += ' </tr>\n'
402             s += (' <tr align="left">\n  <td title="%%(filename)s">%s<br>(%d)</td>\n'
403                   % (self.translation (section_titles_string),
404                      sum (self.masterdocument.word_count))) % self.__dict__
405
406         else:
407             s = (' <tr align="left">\n  <td title="%%(filename)s">%s<br>(%d)</td>\n'
408                  % (self.print_title (numbering),
409                     sum (self.masterdocument.word_count))) % self.__dict__
410
411         if self.partially_translated:
412             s += '  <td>' + '<br>\n   '.join (self.translators) + '</td>\n'
413             s += '  <td>' + '<br>\n   '.join (self.checkers) + '</td>\n'
414         else:
415             s += '  <td></td>\n' * 2
416
417         c = self.completeness (['color', 'short'], translated=True)
418         s += '  <td><span style="background-color: #%(color)s">\
419 %(short)s</span></td>\n' % {'color': c['color'],
420                            'short': c['short']}
421
422         if self.partially_translated:
423             u = self.uptodateness (['short', 'color'], translated=True)
424             s += '  <td><span style="background-color: #%(color)s">\
425 %(short)s</span></td>\n' % {'color': u['color'],
426                            'short': u['short']}
427         else:
428             s += '  <td></td>\n'
429
430         s += '  <td>' + self.gdp_status () + '</td>\n </tr>\n'
431         s += ''.join ([i.translations[self.language].texi_status (numbering)
432                        for i in self.masterdocument.includes
433                        if self.language in i.translations])
434
435         if self.top:
436             s += '</table>\n<p></p>\n'
437         return s
438
439 class IncludedTranslatedTelyDocument (TranslatedTelyDocument):
440     get_level = TelyDocument.get_level
441
442 class UntranslatedTelyDocument (TranslatedTelyDocument):
443     def __init__ (self, filename, masterdocument, parent_translation=None):
444         if filename[2] == '/':
445             self.language = filename[:2]
446         TranslatedTelyDocument.__init__ (self, filename, masterdocument, parent_translation)
447
448 class IncludedUntranslatedTelyDocument (UntranslatedTelyDocument):
449     get_level = TelyDocument.get_level
450
451 class MasterTelyDocument (TelyDocument):
452     def __init__ (self,
453                   filename,
454                   parent_translations=dict ([(lang, None)
455                                              for lang in langdefs.LANGDICT])):
456         TelyDocument.__init__ (self, filename)
457         self.size = len (self.contents)
458         self.word_count = tely_word_count (self.contents)
459         self.translations = {}
460         self.includes = []
461         if not self.language or self.language == 'en':
462             languages = [x for x in parent_translations.keys () if x != 'en']
463             self.translations = dict ([x for x in
464                                        [(lang, self.translated_factory (os.path.join (lang, self.filename),
465                                                                         parent_translations.get (lang)))
466                                         for lang in languages]
467                                        if x[1]])
468             if self.translations:
469                 self.includes = [IncludedMasterTelyDocument (f, self.translations)
470                                  for f in self.included_files]
471
472     def get_level (self):
473         return texi_level ['top']
474
475     def translated_factory (self, filename, parent):
476         if os.path.exists (filename):
477             return TranslatedTelyDocument (filename, self, parent)
478         return None
479
480     def update_word_counts (self, s):
481         s = update_word_count (s, self.filename, sum (self.word_count))
482         for i in self.includes:
483             s = i.update_word_counts (s)
484         return s
485
486     def texi_status (self, numbering=SectionNumber ()):
487         if self.title == 'Untitled' or not self.translations:
488             return ''
489         if self.top:
490             s = '''<table align="center" border="2">
491  <tr align="center">
492   <th>%s</th>''' % self.print_title (numbering)
493             s += ''.join (['  <th>%s</th>\n' % l for l in sorted (self.translations.keys ())])
494             s += ' </tr>\n'
495             s += (' <tr align="left">\n  <td title="%%(filename)s">Section titles<br>(%d)</td>\n'
496                       % sum (self.word_count)) % self.__dict__
497
498         else:  # if self is an included file
499            s = (' <tr align="left">\n  <td title=%%(filename)s>%s<br>(%d)</td>\n'
500                 % (self.print_title (numbering), sum (self.word_count))) % self.__dict__
501
502         s += ''.join ([self.translations[k].short_texi_status ()
503                        for k in sorted (self.translations.keys ())])
504         s += ' </tr>\n'
505         s += ''.join ([i.texi_status (numbering) for i in self.includes])
506
507         if self.top:
508             s += '</table>\n<p></p>\n'
509         return s
510
511     def text_status (self, numbering=SectionNumber (), colspec=[48,12]):
512         if self.title == 'Untitled' or not self.translations:
513             return ''
514
515         s = ''
516         if self.top:
517             s += (self.print_title (numbering) + ' ').ljust (colspec[0])
518             s += ''.join (['%s'.ljust (colspec[1]) % l
519                            for l in sorted (self.translations.keys ())])
520             s += '\n'
521             s += ('Section titles (%d)' % \
522                       sum (self.word_count)).ljust (colspec[0])
523
524         else:
525             s = '%s (%d) ' \
526                 % (self.print_title (numbering), sum (self.word_count))
527             s = s.ljust (colspec[0])
528
529         s += ''.join ([self.translations[k].text_status ().ljust(colspec[1])
530                        for k in sorted (self.translations.keys ())])
531         s += '\n\n'
532         s += ''.join ([i.text_status (numbering) for i in self.includes])
533
534         if self.top:
535             s += '\n'
536         return s
537
538 class IncludedMasterTelyDocument (MasterTelyDocument):
539     get_level = TelyDocument.get_level
540     def translated_factory (self, filename, parent):
541         if os.path.exists (filename):
542             return IncludedTranslatedTelyDocument (filename, self, parent)
543         return IncludedUntranslatedTelyDocument (filename, self, parent)
544
545 update_category_word_counts_re = re.compile (r'(?ms)^-(\d+)-(.*?\n)\d+ *total')
546
547 counts_re = re.compile (r'(?m)^(\d+) ')
548
549 def update_category_word_counts_sub (m):
550     return ('-' + m.group (1) + '-' + m.group (2)
551             + str (sum ([int (c)
552                          for c in counts_re.findall (m.group (2))])).ljust (6)
553             + 'total')
554
555 # urg 
556 # main () starts here-abouts
557
558 progress ("Reading documents...")
559
560 master_files = \
561     buildlib.read_pipe ("git ls-files | grep -E '[^/]*/?[^/]*[.](tely|texi)$'")[0].splitlines ()
562 master_files.sort ()
563 master_docs = [MasterTelyDocument (os.path.normpath (filename))
564                for filename in master_files]
565 master_docs = [doc for doc in master_docs if doc.translations]
566
567 enabled_languages = [l for l in langdefs.LANGDICT
568                      if langdefs.LANGDICT[l].enabled
569                      and l != 'en']
570
571 progress ("Generating status pages...")
572
573 date_time = buildlib.read_pipe ('LANG= date -u')[0]
574
575 main_status_body = last_updated_string % date_time
576 main_status_body += '\n'.join ([doc.texi_status () for doc in master_docs])
577
578 texi_header = '''@c -*- coding: utf-8; mode: texinfo; -*-
579 @c This file was generated by translation-status.py -- DO NOT EDIT!
580 @ignore
581     Translation of GIT committish: 0
582 @end ignore
583
584 @ifnothtml
585 Translation status currently only available in HTML.
586 @end ifnothtml
587 @ifhtml
588 @html
589 '''
590
591 texi_footer = '''
592 @end html
593 @end ifhtml
594 '''
595
596 main_status_page = texi_header % locals () + main_status_body + texi_footer
597
598 open ('translations.itexi', 'w').write (main_status_page)
599
600 for l in enabled_languages:
601     date_time = buildlib.read_pipe ('LANG=%s date -u' % l)[0]
602     updated = translation[l] (last_updated_string) % date_time
603     texi_status = '\n'.join ([doc.translations[l].texi_status ()
604                               for doc in master_docs
605                               if l in doc.translations])
606     lang_status_page = texi_header + updated + texi_status + texi_footer
607     open (os.path.join (l, 'translations.itexi'), 'w').write (lang_status_page)
608
609 main_status_txt = '''Documentation translations status
610 Generated %s
611 NT = not translated
612 FT = fully translated
613
614 ''' % date_time
615
616 main_status_txt += '\n'.join ([doc.text_status () for doc in master_docs])
617
618 status_txt_file = 'out/translations-status.txt'
619 progress ("Writing %s..." % status_txt_file)
620 open (status_txt_file, 'w').write (main_status_txt)
621
622 translation_instructions_file = 'contributor/doc-translation-list.itexi'
623 progress ("Updating %s..." % translation_instructions_file)
624 translation_instructions = open (translation_instructions_file).read ()
625
626 for doc in master_docs:
627     translation_instructions = doc.update_word_counts (translation_instructions)
628
629 for html_file in re.findall (r'(?m)^\d+ *(\S+?\.html\S*?)(?: |$)',
630                              translation_instructions):
631     word_count = sgml_word_count (open (html_file).read ())
632     translation_instructions = update_word_count (translation_instructions,
633                                                   html_file,
634                                                   word_count)
635
636 for po_file in re.findall (r'(?m)^\d+ *(\S+?\.po\S*?)(?: |$)',
637                            translation_instructions):
638     word_count = po_word_count (open (po_file).read ())
639     translation_instructions = update_word_count (translation_instructions,
640                                                   po_file,
641                                                   word_count)
642
643 translation_instructions = \
644     update_category_word_counts_re.sub (update_category_word_counts_sub,
645                                         translation_instructions)
646
647 open (translation_instructions_file, 'w').write (translation_instructions)
648 sys.exit (exit_code)