X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=buildscripts%2Ftexi-langutils.py;h=a2d8958f569ccca6d998bb627de609e41f8f987a;hb=ece2e45d587f63565e81af44e1937ebe1f5e47a8;hp=4e54169dd0fa3ebcb1838b34f78a9960aeec5e51;hpb=46f29bab40e008c63440ae17f47661cf04f41202;p=lilypond.git diff --git a/buildscripts/texi-langutils.py b/buildscripts/texi-langutils.py index 4e54169dd0..a2d8958f56 100644 --- a/buildscripts/texi-langutils.py +++ b/buildscripts/texi-langutils.py @@ -26,13 +26,11 @@ make_skeleton = ('--skeleton', '') in optlist # --skeleton extract the node tr output_file = 'doc.pot' node_blurb = '' doclang = '' -topfile = os.path.basename (texi_files[0]) head_committish = read_pipe ('git-rev-parse HEAD') intro_blurb = '''@c -*- coding: utf-8; mode: texinfo%(doclang)s -*- @c This file is part of %(topfile)s @ignore Translation of GIT committish: %(head_committish)s - When revising a translation, copy the HEAD committish of the version that you are working on. See TRANSLATION for details. @end ignore @@ -57,10 +55,7 @@ for x in optlist: doclang = '; documentlanguage: ' + x[1] -intro_blurb = intro_blurb % vars() - - -def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, output_file=None): +def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, topfile, output_file=None): try: f = open (texifilename, 'r') texifile = f.read () @@ -68,7 +63,9 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, output_file=No includes = [] if write_skeleton: g = open (os.path.basename (texifilename), 'w') - g.write (i_blurb) + subst = globals () + subst.update (locals ()) + g.write (i_blurb % subst) tutu = re.findall (r"""^(\*) +([^: ]+)::[^ ]*?$|^@(include|menu|end menu|node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading) *([^ @@ -79,7 +76,7 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, output_file=No if item[0] == '*': g.write ('* ' + item[1] + '::\n') elif output_file and item[4] == 'rglos': - output_file.write ('_("' + item[5] + '") # @rglos in ' + texifilename + '\n') + output_file.write ('_(r"' + item[5] + '") # @rglos in ' + texifilename + '\n') else: g.write ('@' + item[2] + ' ' + item[3] + '\n') if node_trigger: @@ -87,7 +84,7 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, output_file=No node_trigger = False if not item[2] in ('include', 'menu', 'end menu'): if output_file: - output_file.write ('_("' + item[3].strip () + '") # @' + item[2] + \ + output_file.write ('_(r"' + item[3].strip () + '") # @' + item[2] + \ ' in ' + texifilename + '\n') if item[2] == 'node': node_trigger = True @@ -103,13 +100,13 @@ def process_texi (texifilename, i_blurb, n_blurb, write_skeleton, output_file=No if item[0] == 'include': includes.append(item[1]) elif item[2] == 'rglos': - output_file.write ('# @rglos in ' + texifilename + '\n_("' + item[3] + '")\n') + output_file.write ('# @rglos in ' + texifilename + '\n_(r"' + item[3] + '")\n') else: - output_file.write ('# @' + item[0] + ' in ' + texifilename + '\n_("' + item[1].strip () + '")\n') + output_file.write ('# @' + item[0] + ' in ' + texifilename + '\n_(r"' + item[1].strip () + '")\n') if process_includes: dir = os.path.dirname (texifilename) for item in includes: - process_texi (os.path.join (dir, item.strip ()), i_blurb, n_blurb, write_skeleton, output_file) + process_texi (os.path.join (dir, item.strip ()), i_blurb, n_blurb, write_skeleton, topfile, output_file) except IOError, (errno, strerror): print "I/O error(%s): %s: %s" % (errno, texifilename, strerror) @@ -121,12 +118,13 @@ if node_blurb != '': if make_gettext: node_list_filename = 'node_list' node_list = open (node_list_filename, 'w') + node_list.write ('# -*- coding: utf-8 -*-\n') for texi_file in texi_files: - process_texi (texi_file, intro_blurb, node_blurb, make_skeleton, node_list) - for word in ('Up:', 'Next:', 'Previous:', 'Appendix', 'Footnotes', 'Table of Contents'): - node_list.write ('_("' + word + '")\n') + process_texi (texi_file, intro_blurb, node_blurb, make_skeleton, os.path.basename (texi_file), node_list) + for word in ('Up:', 'Next:', 'Previous:', 'Appendix ', 'Footnotes', 'Table of Contents'): + node_list.write ('_(r"' + word + '")\n') node_list.close () os.system ('xgettext -c -L Python --no-location -o ' + output_file + ' ' + node_list_filename) else: for texi_file in texi_files: - process_texi (texi_file, intro_blurb, node_blurb, make_skeleton) + process_texi (texi_file, intro_blurb, node_blurb, make_skeleton, os.path.basename (texi_file))