5 Documentation i18n module
12 def lang_file_name (p, langext, ext):
14 return p + '.' + langext + ext
18 def __init__ (self, code, name, webext=None, double_punct_char_sep='', html_filter=lambda s: s, enable_ly_identifier_l10n=True):
23 self.webext = self.code
26 self.double_punct_char_sep = double_punct_char_sep
27 self.html_filter = html_filter
28 self.enable_ly_identifier_l10n = enable_ly_identifier_l10n
29 def file_name (self, prefix, ext):
30 return lang_file_name (prefix, self.webext, ext)
33 # All language information needed for documentation i18n is defined
34 # here. For each 'Documentation/ab' directory containing docs
35 # translated in 'ab', there should be one entry in LANGUAGES.
37 site = LanguageDef ('en', 'English', webext='')
39 html_body_re = re.compile ('<body.*?>', re.I)
40 html_end_body_re = re.compile ('</body>', re.I)
41 french_html_typo_rules = ((' :', ' :'),
43 (' ?', '<font size="-4"> </font>?'),
44 (' !', '<font size="-4"> </font>!'))
46 def french_html_filter (page):
47 m = html_body_re.search (page)
52 m = html_end_body_re.search (page)
57 body = page[body_begin:body_end]
58 for r in french_html_typo_rules:
59 body = body.replace (r[0], r[1])
60 return page[:body_begin] + body + page[body_end:]
62 fr = LanguageDef ('fr', 'français', double_punct_char_sep=' ', html_filter = french_html_filter)
63 es = LanguageDef ('es', 'español')
64 de = LanguageDef ('de', 'deutsch')
65 ja = LanguageDef ('ja', '日本語', enable_ly_identifier_l10n=False)
67 # Outdated or broken translations may be disabled
68 # (please run 'make doc-clean' before doing that):
71 LANGUAGES = (site, fr, es, de, ja)
73 if __name__ == '__main__':
74 print ' '.join ([l.code for l in LANGUAGES if l.enabled and l.code != 'en'])
85 if l.enabled and l.code != 'en':
86 t = gettext.translation('lilypond-doc',
87 os.environ['LYDOC_LOCALEDIR'],
89 translation[l.code] = t.gettext
91 if os.environ.has_key ('LYDOC_LOCALEDIR'):
92 sys.stderr.write ('langdefs.py: warning: lilypond-doc gettext domain not found.\n')
93 translation = dict ([(l.code, lambda x: x) for l in LANGUAGES])