- if not os.path.splitext (file_name)[1] == '.texidoc':
- raise Exception ('cannot determine language for ' + file_name)
- translated_contents = open (file_name).read ()
- if 'ISOLANG' in os.environ:
- preferred_language = os.environ['ISOLANG']
- else:
- raise Exception ('cannot determine language for ' + file_name)
- for m in texidoc_chunk_re.finditer (translated_contents):
- if m.group (2) == preferred_language:
- full_translated_contents = translated_contents
- translated_contents = m.group (1)
- translated_contents_start = m.start ()
- translated_contents_end = m.end ()
- break
- else:
- return
- original = file_name.replace ('texidocs' + os.path.sep, 'lsr' + os.path.sep, 1)
- original = original.replace ('.texidoc', '.ly', 1)
-
- # URG dirty .texidoc files manipulation in a dirty way
- if touch_committishes and buildlib.check_translated_doc (original,
- file_name,
- translated_contents,
- color=use_colors and not update_mode)[1]:
- (estimated_revision, error) = buildlib.read_pipe (vc_last_texidoc_revision % vars ())
- if error:
- sys.stderr.write ('warning: %s: %s' % (file_name, error))
- estimated_revision = estimated_revision.strip ()
- translated_contents = re.sub (r'(?m)^%+\s*Translation of GIT committish:.*\n', '', translated_contents)
- f = open (file_name, 'w')
- f.write (full_translated_contents[:translated_contents_start])
- f.write ('%% Translation of GIT committish: ' + estimated_revision + '\n')
- f.write (translated_contents)
- f.write (full_translated_contents[translated_contents_end:])
- return
-