From c74bf739ec32b015c711c460aa831092a08478b3 Mon Sep 17 00:00:00 2001 From: John Mandereau Date: Wed, 15 Jul 2009 00:14:12 +0200 Subject: [PATCH] Docs: prepare direct translation of node names in Texinfo sources - fix nits in texi-gettext.py, - update tely-gettext.py and extract_texi_filenames.py, - use --master-map-file option of extract_texi_filenames.py added in this commit, - remove embarrassing node translations in French and Spanish doc POs. All these updates have been tested with a few makefiles hooks (not included in this commit), an apparently successful execution of tely-gettext.py on all translations followed by 'make doc' and a quick check of HTML and PDF output. Signed-off-by: Patrick McCarty --- Documentation/po/es.po | 37 +++++++++----- Documentation/po/fr.po | 10 ++-- make/doc-i18n-user-rules.make | 4 +- scripts/auxiliar/tely-gettext.py | 33 ++++++------- scripts/build/extract_texi_filenames.py | 64 +++++++++++++++++++------ scripts/build/texi-gettext.py | 4 +- 6 files changed, 98 insertions(+), 54 deletions(-) diff --git a/Documentation/po/es.po b/Documentation/po/es.po index 2926432272..2dd7809bba 100644 --- a/Documentation/po/es.po +++ b/Documentation/po/es.po @@ -1,15 +1,30 @@ -# translation of es.po to Español -# translation of LilyPond documentation -# Copyright (C) 2006 Han-Wen Nienhuys, Jan Nieuwenhuizen -# This file is distributed under the same license as the lilypond package. +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# FIRST AUTHOR , YEAR. # -# Francisco Vila , 2007, 2008. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: es\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-12-25 12:33+0100\n" -"PO-Revision-Date: 2008-12-20 17:45+0100\n" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#~ # translation of es.po to Español +#~ # translation of LilyPond documentation +#~ # Copyright (C) 2006 Han-Wen Nienhuys, Jan Nieuwenhuizen +#~ # This file is distributed under the same license as the lilypond package. +#~ # +#~ # Francisco Vila , 2007, 2008, 2009. +#~ msgid "" +#~ msgstr "" +#~ "Project-Id-Version: es\n" +#~ "Report-Msgid-Bugs-To: \n" +#~ "POT-Creation-Date: 2009-07-06 23:05+0200\n" +"PO-Revision-Date: 2009-07-14 18:12+0200\n" "Last-Translator: Francisco Vila \n" "Language-Team: Español\n" "MIME-Version: 1.0\n" @@ -155,7 +170,7 @@ msgstr "post-GDP" #. @node in Documentation/de/user/lilypond-program.tely #. @node in Documentation/de/user/lilypond.tely msgid "Top" -msgstr "Inicio" +msgstr "" #. @top in Documentation/user/lilypond-learning.tely msgid "GNU LilyPond --- Learning Manual" @@ -3481,7 +3496,7 @@ msgstr "Trucos con Scheme" #. @node in Documentation/user/fdl.itexi #. @appendix in Documentation/user/fdl.itexi msgid "GNU Free Documentation License" -msgstr "Licencia de documentación libre de GNU" +msgstr "" #. @subheading in Documentation/user/fdl.itexi msgid "ADDENDUM: How to use this License for your documents" diff --git a/Documentation/po/fr.po b/Documentation/po/fr.po index 3934e0ba8a..b08f1f5174 100644 --- a/Documentation/po/fr.po +++ b/Documentation/po/fr.po @@ -8,9 +8,9 @@ msgid "" msgstr "" "Project-Id-Version: fr\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-12-25 12:33+0100\n" -"PO-Revision-Date: 2009-01-04 17:50+0100\n" -"Last-Translator: Jean-Charles Malahieude \n" +"POT-Creation-Date: 2009-07-06 23:05+0200\n" +"PO-Revision-Date: 2009-07-14 18:04+0200\n" +"Last-Translator: Jean-Charles Malahieude \n" "Language-Team: Français \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -157,7 +157,7 @@ msgstr "post-GDP" #. @node in Documentation/de/user/lilypond-program.tely #. @node in Documentation/de/user/lilypond.tely msgid "Top" -msgstr "Sommaire" +msgstr "" #. @top in Documentation/user/lilypond-learning.tely msgid "GNU LilyPond --- Learning Manual" @@ -3482,7 +3482,7 @@ msgstr "Scheme et les retouches" #. @node in Documentation/user/fdl.itexi #. @appendix in Documentation/user/fdl.itexi msgid "GNU Free Documentation License" -msgstr "Licence GNU de documentation libre" +msgstr "" #. @subheading in Documentation/user/fdl.itexi msgid "ADDENDUM: How to use this License for your documents" diff --git a/make/doc-i18n-user-rules.make b/make/doc-i18n-user-rules.make index 30ef6bd70f..75a6497f4f 100644 --- a/make/doc-i18n-user-rules.make +++ b/make/doc-i18n-user-rules.make @@ -21,8 +21,8 @@ $(outdir)/version.%: $(top-src-dir)/VERSION $(outdir)/%.png: $(top-build-dir)/Documentation/user/$(outdir)/%.png ln -f $< $@ -$(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map: $(outdir)/%.texi - $(buildscript-dir)/extract_texi_filenames -o $(XREF_MAPS_DIR) $< +$(XREF_MAPS_DIR)/%.$(ISOLANG).xref-map: $(outdir)/%.texi $(XREF_MAPS_DIR)/%.xref-map + $(buildscript-dir)/extract_texi_filenames -o $(XREF_MAPS_DIR) --master-map-file=$(XREF_MAPS_DIR)/$*.xref-map $< $(MASTER_TEXI_FILES): $(ITELY_FILES) $(ITEXI_FILES) diff --git a/scripts/auxiliar/tely-gettext.py b/scripts/auxiliar/tely-gettext.py index 341816a7db..97ed5dcd88 100755 --- a/scripts/auxiliar/tely-gettext.py +++ b/scripts/auxiliar/tely-gettext.py @@ -4,34 +4,29 @@ # Temporary script that helps translated docs sources conversion # for texi2html processing -# USAGE: tely-gettext.py PYTHON-DIR LOCALEDIR LANG FILES +# USAGE: tely-gettext.py LANG FILES print "tely-gettext.py" import sys import re import os -import gettext -if len (sys.argv) > 3: - buildscript_dir, localedir, lang = sys.argv[1:4] -else: - print """USAGE: tely-gettext.py PYTHON-DIR LOCALEDIR LANG FILES - For example scripts/auxiliar/tely-gettext.py python/out Documentation/po/out-www de Documentation/de/user/*.tely""" - sys.exit (1) - -sys.path.append (buildscript_dir) import langdefs +lang = sys.argv[1] +files = sys.argv[2:] + double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep -t = gettext.translation('lilypond-doc', localedir, [lang]) -_doc = t.gettext +_doc = langdefs.translation[lang] include_re = re.compile (r'@include (.*?)$', re.M) whitespaces = re.compile (r'\s+') ref_re = re.compile (r'(?ms)@(ruser|rprogram|ref|rlearning)\{(.*?)\}') node_section_re = re.compile (r'@node (.*?)\n@((?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading) (.*?)\n') menu_entry_re = re.compile (r'\* (.*?)::') +untranslated_node_re = re.compile (r'(@node\s+.*\n@.*\n.*)(\s+@untranslated(.|\n)+?)(?=@node|@subheading|@menu|$)') + def ref_gettext (m): r = whitespaces.sub (' ', m.group (2)) @@ -40,7 +35,7 @@ def ref_gettext (m): def node_gettext (m): return '@node ' + _doc (m.group (1)) + '\n@' + \ m.group (2) + ' ' + _doc (m.group (3)) + \ - '\n@translationof ' + m.group (1) + '\n' + '\n@translationof ' + m.group (1) + '\n' def menu_entry_gettext (m): return '* ' + _doc (m.group (1)) + '::' @@ -53,11 +48,11 @@ def process_file (filename): page = node_section_re.sub (node_gettext, page) page = ref_re.sub (ref_gettext, page) page = menu_entry_re.sub (menu_entry_gettext, page) - page = page.replace ("""-- SKELETON FILE -- -When you actually translate this file, please remove these lines as -well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", """@c -- SKELETON FILE --""") - page = page.replace ('UNTRANSLATED NODE: IGNORE ME', "@c UNTRANSLATED NODE: IGNORE ME") - includes = [whitespaces.sub ('', f) for f in include_re.findall (page)] + page = page.replace ("""@c -- SKELETON FILE -- +""", '') + page = page.replace ('UNTRANSLATED NODE: IGNORE ME', '@untranslated') + page = untranslated_node_re.sub ('\\1 @c external\\2', page) + includes = include_re.findall (page) f = open (filename, 'w') f.write (page) f.close () @@ -67,5 +62,5 @@ well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", """@c -- SKELETON FILE --" if os.path.exists (p): process_file (p) -for filename in sys.argv[4:]: +for filename in files: process_file (filename) diff --git a/scripts/build/extract_texi_filenames.py b/scripts/build/extract_texi_filenames.py index 8848b40511..bf0c6da5ed 100644 --- a/scripts/build/extract_texi_filenames.py +++ b/scripts/build/extract_texi_filenames.py @@ -26,8 +26,10 @@ import re import os import getopt -options_list, files = getopt.getopt (sys.argv[1:],'o:s:hI:', - ['output=', 'split=', 'help', 'include=']) +options_list, files = getopt.getopt (sys.argv[1:],'o:s:hI:m:', + ['output=', 'split=', + 'help', 'include=', + 'master-map-file=']) help_text = r"""Usage: %(program_name)s [OPTIONS]... TEXIFILE... Extract files names for texinfo (sub)sections from the texinfo files. @@ -35,6 +37,7 @@ Extract files names for texinfo (sub)sections from the texinfo files. Options: -h, --help print this help -I, --include=DIRECTORY append DIRECTORY to include search path + -m, --master-map-file=FILE use FILE as master map file -o, --output=DIRECTORY write .xref-map files to DIRECTORY -s, --split=MODE split manual according to MODE. Possible values are section and custom (default) @@ -47,6 +50,8 @@ def help (text): outdir = '.' split = "custom" include_path = [] +master_map_file = '' +initial_map = {} for opt in options_list: o = opt[0] a = opt[1] @@ -59,6 +64,9 @@ for opt in options_list: outdir = a elif o == '-s' or o == '--split': split = a + elif o == '-m' or o == '--master-map-file': + if os.path.isfile (a): + master_map_file = a else: raise Exception ('unknown option: ' + o) @@ -72,7 +80,9 @@ include_re = re.compile (r'@include ((?!../lily-).*?\.i?texi)$', re.M) whitespaces = re.compile (r'\s+') section_translation_re = re.compile ('^@(node|(?:unnumbered|appendix)\ (?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|\ -(?:major|chap|(?:sub){0,2})heading|translationof|lydoctitle) (.*?)\\s*$', re.MULTILINE) +(?:major|chap|(?:sub){0,2})heading|lydoctitle|translationof) \ +(.+)$', re.MULTILINE) +external_node_re = re.compile (r'\s+@c\s+external.*') def expand_includes (m, filename): filepath = os.path.join (os.path.dirname (filename), m.group(1)) @@ -106,8 +116,8 @@ def extract_sections (filename): result += "@" + sec[0] + " " + sec[1] + "\n" return (lang_suffix, result) -# Convert a given node name to its proper file name (normalization as explained -# in the texinfo manual: +# Convert a given node name to its proper file name (normalization as +# explained in the texinfo manual: # http://www.gnu.org/software/texinfo/manual/texinfo/html_node/HTML-Xref-Node-Name-Expansion.html def texinfo_file_name(title): # exception: The top node is always mapped to index.html @@ -180,24 +190,39 @@ def process_sections (filename, lang_suffix, page): had_section = False for sec in sections: if sec[0] == "node": - # Write out the cached values to the file and start a new section: + # Write out the cached values to the file and start a new + # section: if this_title and this_title != 'Top': f.write (this_title + "\t" + this_filename + "\t" + this_anchor + "\n") had_section = False this_title = remove_texinfo (sec[1]) this_anchor = create_texinfo_anchor (sec[1]) + # delete entry from master map file + if this_title in initial_map: + del initial_map[this_title] elif sec[0] == "translationof": + print sec + (original_node, external_node) = external_node_re.subn ('', sec[1]) + original_node = remove_texinfo (original_node) + # The following binds the translator to use the + # translated node name in cross-references in case + # it exists + if external_node and original_node in initial_map: + del initial_map[original_node] anchor = create_texinfo_anchor (sec[1]) - # If @translationof is used, it gives the original node name, which - # we use for the anchor and the file name (if it is a numbered node) + # If @translationof is used, it gives the original + # node name, which we use for the anchor and the file + # name (if it is a numbered node) this_anchor = anchor if not this_unnumbered: this_filename = anchor + elif original_node in initial_map: + this_filename = initial_map[original_node][2] else: - # Some pages might not use a node for every section, so treat this - # case here, too: If we already had a section and encounter another - # one before the next @node, we write out the old one and start - # with the new values + # Some pages might not use a node for every section, so + # treat this case here, too: If we already had a section + # and encounter another one before the next @node, we + # write out the old one and start with the new values if had_section and this_title: f.write (this_title + "\t" + this_filename + "\t" + this_anchor + "\n") this_title = remove_texinfo (sec[1]) @@ -205,9 +230,9 @@ def process_sections (filename, lang_suffix, page): had_section = True if split == 'custom': - # unnumbered nodes use the previously used file name, only numbered - # nodes get their own filename! However, top-level @unnumbered - # still get their own file. + # unnumbered nodes use the previously used file name, + # only numbered nodes get their own filename! However, + # top-level @unnumbered still get their own file. this_unnumbered = unnumbered_re.match (sec[0]) if not this_unnumbered: this_filename = this_anchor @@ -220,8 +245,17 @@ def process_sections (filename, lang_suffix, page): if this_title and this_title != 'Top': f.write (this_title + "\t" + this_filename + "\t" + this_anchor + "\n") + + for node in initial_map: + f.write ("\t".join (initial_map[node]) + "\n") f.close () +xref_map_line_re = re.compile (r'(.*?)\t(.*?)\t(.*?)$') +if master_map_file: + for line in open (master_map_file): + m = xref_map_line_re.match (line) + if m: + initial_map[m.group (1)] = (m.group (1), m.group (2), m.group (3)) for filename in files: print "extract_texi_filenames.py: Processing %s" % filename diff --git a/scripts/build/texi-gettext.py b/scripts/build/texi-gettext.py index 546819b155..7ce17cb49a 100644 --- a/scripts/build/texi-gettext.py +++ b/scripts/build/texi-gettext.py @@ -7,7 +7,7 @@ # -o OUTDIR specifies that output files should rather be written in OUTDIR # -print "texi_gettext.py" +print "texi-gettext.py" import sys import re @@ -30,7 +30,7 @@ _doc = langdefs.translation[lang] include_re = re.compile (r'@include ((?!../lily-).*?)\.texi$', re.M) whitespaces = re.compile (r'\s+') -ref_re = re.compile (r'(?ms)@(rglos|ruser|rprogram|ref)(\{)(.*?)(\})') +ref_re = re.compile (r'(?ms)@(rglos|ruser|rprogram|ref|rlearning)(\{)(.*?)(\})') node_section_re = re.compile (r'@(node|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)( )(.*?)(\n)') menu_entry_re = re.compile (r'\* (.*?)::') -- 2.39.2