4 # USAGE: texi-gettext.py [-o OUTDIR] BUILDSCRIPT-DIR LOCALEDIR LANG FILES
6 # -o OUTDIR specifies that output files should be written in OUTDIR
7 # rather than be overwritten
16 optlist, args = getopt.getopt(sys.argv[1:],'o:')
17 buildscript_dir, localedir, lang = args[0:3]
24 sys.path.append (buildscript_dir)
27 double_punct_char_separator = langdefs.LANGDICT[lang].double_punct_char_sep
28 t = gettext.translation('lilypond-doc', localedir, [lang])
31 include_re = re.compile (r'@include (.*?)$', re.M)
33 def title_gettext (m):
34 return '@' + m.group (1) + m.group (2) + _doc (m.group (3)) + m.group (4)
36 def process_file (filename):
37 print "Processing %s" % filename
38 f = open (filename, 'r')
41 page = re.sub (r'(?L)@(rglos|(?:unnumbered|appendix)(?:(?:sub){0,2}sec)?|top|chapter|(?:sub){0,2}section|(?:major|chap|(?:sub){0,2})heading)(\{| )(.*?)(\}|\n)', title_gettext, page)
42 page = page.replace ("""-- SKELETON FILE --
43 When you actually translate this file, please remove these lines as
44 well as all `UNTRANSLATED NODE: IGNORE ME' lines.""", '')
45 page = page.replace ('UNTRANSLATED NODE: IGNORE ME', _doc ("This section has not been translated yet; please refer to the manual in English."))
46 f = open (os.path.join (outdir, filename), 'w')
49 dir = os.path.dirname (filename)
50 for file in include_re.findall (page):
51 p = os.path.join (dir, file)
52 if os.path.exists (p):
55 for filename in args[3:]:
56 process_file (filename)
58 toto = raw_input ("Press enter to continue")