2 # -*- coding: utf-8 -*-
3 # create-version-itexi.py
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
12 ### translation data -- shouldn't be here; see issue
13 ### http://code.google.com/p/lilypond/issues/detail?id=1050
16 # GUB only has python 2.4 !!!
17 # langs = [i.code if i.code != 'en' else '' for i in langdefs.WEB_LANGUAGES]
19 for lang in langdefs.WEB_LANGUAGES:
23 langs.append(lang.code)
26 # these links are relative from /website/ on lilypond.org
29 # Get/update node translations
31 for i in cs de es fr hu it ja nl zh; do
33 (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
34 | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
35 | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
43 'Learning': 'Einführung',
44 'Music glossary': 'Glossar',
46 'Notation': 'Notation',
48 'Snippets': 'Schnipsel',
50 'Changes': 'Änderungen',
52 'Extending': 'Erweitern',
53 'Internals': 'Interna',
54 'Contributor': 'Beitragen',
56 ' (split HTML)': ' (geteiltes HTML)',
57 ' (big HTML)': ' (großes HTML)',
59 'Regression tests for ': 'Regressionstests für ',
60 'PDF of regtests for ': 'PDF der Regressionstests für ',
61 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
62 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
64 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
65 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
68 'Source': 'Código fuente',
70 'Learning': 'Aprendizaje',
71 'Music glossary': 'Glosario',
73 'Notation': 'Notación',
74 'Usage': 'Utilización',
75 'Snippets': 'Fragmentos',
78 'Extending': 'Extensión',
79 'Internals': 'Funcionamiento interno',
80 'Contributor': 'Guía del colaborador',
83 ' (split HTML)': ' (HTML seccionado)',
84 ' (big HTML)': ' (HTML monolítico)',
86 'Regression tests for ': 'Pruebas de regresión para ',
87 'PDF of regtests for ': 'Pruebas en PDF para ',
88 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
89 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
91 'Doc tarball for ': 'Tarball de la documentación para ',
92 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
97 'Learning': 'Initiation',
98 'Music glossary': 'Glossaire',
100 'Notation': 'Notation',
101 'Usage': 'Utilisation',
102 'Snippets': 'Morceaux choisis',
104 'Changes': 'Nouveautés',
105 'Extending': 'Extension',
106 'Internals': 'Propriétés internes',
107 'Contributor': 'Guide du contributeur',
110 ' (split HTML)': ' (HTML multipages)',
111 ' (big HTML)': ' (HTML en page unique)',
113 'Regression tests for ': 'Tests de régression pour ',
114 'PDF of regtests for ': 'PDF des tests de régression pour ',
115 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
116 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
118 'Doc tarball for ': 'Archive de la documentation pour ',
119 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
123 'Learning': 'Tankönyv',
124 'Music glossary': 'Fogalomtár',
126 'Notation': 'Kottaírás',
127 'Usage': 'Használat',
128 'Snippets': 'Kódrészletek',
130 'Changes': 'Változások',
131 'Extending': 'Bővítés',
132 'Internals': 'Belső működés',
133 'Contributor': 'Közreműködés',
135 ' (split HTML)': ' (HTML oldalak)',
136 ' (big HTML)': ' (egy nagy HTML oldal)',
138 'Regression tests for ': 'Regressziós tesztek - verzió: ',
139 'PDF of regtests for ': 'PDF formátumban - verzió: ',
140 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
141 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
143 'Doc tarball for ': 'Tömörített csomag - verzió: ',
144 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
149 'Music glossary': '用語集',
153 'Snippets': 'コード断片集',
159 'Internals': '内部リファレンス',
160 'Contributor': '貢献者向けガイド',
163 ' (split HTML)': ' (ページ毎に分割された HTML)',
164 ' (big HTML)': ' (1 つの大きな HTML)',
166 'Regression tests for ': '回帰テスト バージョン ',
167 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
168 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
169 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
171 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
172 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
176 'Source': 'Broncode',
178 'Learning': 'Beginnen',
179 'Music glossary': 'Terminologie',
181 'Notation': 'Notatie',
183 'Snippets': 'Snippers',
185 'Changes': 'Veranderingen',
186 'Extending': 'Uitbreidingen',
187 'Internals': 'Internals',
188 'Contributor': 'Contributor',
191 ' (split HTML)': ' (opgesplitste HTML)',
192 ' (big HTML)': ' (grote pagina HTML)',
194 'Regression tests for ': 'Regressietesten voor ',
195 'PDF of regtests for ': 'PDF van regressietesten voor ',
196 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
197 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
199 'Doc tarball for ': 'Tarball met documentation voor ',
200 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
205 'Music glossary': '音乐术语表',
215 'Contributor': '贡献者',
218 ' (split HTML)': ' (分开的HTML',
219 ' (big HTML)': ' (大的HTML)',
221 'Regression tests for ': '回归测试',
222 'PDF of regtests for ': '回归的PDF',
223 'MusicXML Regression tests for ': 'MusicXML回归测试',
224 'PDF of MusicXML regtests for ': 'MusicXML的PDF回归',
226 'Doc tarball for ': '为文档压缩包',
227 ' (did not exist in 2.12)': ' (在2.12中不存在)',
243 myDir = os.path.dirname(sys.argv[0])
244 # use two abspaths to work around some windows python bug
245 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
246 topDir = os.path.abspath( topDir )
249 # TODO: this might be useful for other scripts; can we make it available?
250 manuals = map(lambda x: os.path.splitext(x)[0],
251 map(os.path.basename,
252 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
253 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
254 manuals.append('internals')
257 version_file_path = os.path.join(topDir, "VERSION")
259 version_contents = open(version_file_path).readlines()
263 for line in version_contents:
264 if (line.startswith('MAJOR_VERSION')):
266 if (line.startswith('MINOR_VERSION')):
268 if (line.startswith('PATCH_LEVEL')):
270 if (line.startswith('VERSION_STABLE')):
271 VERSION_STABLE = line[15:-1]
272 if (line.startswith('VERSION_DEVEL')):
273 VERSION_DEVEL = line[14:-1]
275 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
277 def _ (string, lang):
278 return translations.get (lang.split ('_')[0], {}).get (string, string)
281 # let's not barf, but print a warning when something's missing
282 def getTrans(text, lang):
283 trans = _ (text, lang)
286 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
289 def macroLang(name, lang):
291 return name + '-' + lang
294 def make_macro(name, string):
300 def make_download(name, osA, osB, version, revision, text):
301 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
302 string += osA + "lilypond-"
303 string += version + "-" + revision
304 string += "." + osB + ",\n"
306 string += ": LilyPond "
307 string += version + "-" + revision
309 make_macro(name, string)
311 def make_download_source(name, vstring, version, lang):
312 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
313 string += vstring + "/"
314 string += "lilypond-" + version + ".tar.gz"
316 string += getTrans("Source", lang)
317 string += ": lilypond-" + version + ".tar.gz"
319 make_macro(macroLang(name,lang), string)
321 def make_all_downloads(macroName, version):
322 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
323 "linux-x86.sh", version, "1", "Linux x86")
324 make_download("download"+macroName+"LinuxBig", "linux-64/",
325 "linux-64.sh", version, "1", "Linux 64")
326 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
327 "linux-ppc.sh", version, "1", "Linux PPC")
329 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
330 "freebsd-x86.sh", version, "1", "FreeBSD i386")
331 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
332 "freebsd-64.sh", version, "1", "FreeBSD amd64")
334 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
335 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
336 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
337 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
339 make_download("download"+macroName+"Windows", "mingw/",
340 "mingw.exe", version, "1", "Windows")
342 def make_ver_link(macroname, url, linktext):
348 make_macro(macroname, string)
350 # TODO: this kind of thing should really be in a central place for
351 # lilypond python build scripts
352 def translateNameToUrl(manual, version):
353 ver_split = version.split('.')
354 ver_minor = ver_split[0] + '.' + ver_split[1]
355 url = depth + "doc/v" + ver_minor + "/Documentation/"
357 if (ver_minor == '2.12'):
358 if (manual=='learning'):
359 return url+'user/lilypond-learning'
360 elif (manual=='internals'):
361 return url+'user/lilypond-internals'
362 elif (manual=='notation'):
363 return url+'user/lilypond'
364 elif (manual=='usage'):
365 return url+'user/lilypond-program'
366 elif (manual=='snippets'):
367 return url+'../input/lsr/lilypond-snippets'
368 elif (manual=='changes'):
369 return url+'topdocs/NEWS.html'
370 elif (manual=='music-glossary'):
371 return url+'user/music-glossary'
372 elif (manual=='essay'):
373 return url+'user/lilypond-learning/Background.html'
374 elif (manual=='extending'):
375 return url+'user/lilypond/Interfaces-for-programmers.html'
381 def addLang(url, lang):
383 base, ext = os.path.splitext(url)
384 return base + '.' + lang + ext
388 def make_manual_links(name, version, lang):
389 """Here is where all the macros manualStableLearningSplit,
390 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
391 created on the fly. Hopefully this documentation string will help
392 others a bit while grepping for those.
396 # TODO: this is a stupid way of doing it
397 if (m=='music-glossary'):
400 mshort = m.capitalize()
401 if (manual=='music-glossary'):
402 manual = 'Music glossary'
403 url = translateNameToUrl(m, version)
406 # can't have a comma here due to texinfo
407 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
408 "http://lilypond.org",
409 mshort+getTrans(" (did not exist in 2.12)",lang))
410 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
411 "http://lilypond.org",
412 mshort+getTrans(" (did not exist in 2.12)",lang))
413 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
414 "http://lilypond.org",
415 mshort+getTrans(" (did not exist in 2.12)",lang))
416 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
417 "http://lilypond.org",
418 mshort+getTrans(" (did not exist in 2.12)",lang))
420 # this is stupid and I shouldn't have bothered trying
421 # to support the 2.12 docs and it will be deleted once
422 # 2.14 is out and the website won't be visible to users
423 # until 2.14 is out. -gp
424 if (url.endswith('.html')):
425 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
427 getTrans(manual.capitalize(),lang) + '.pdf')
428 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
430 getTrans(manual.capitalize(),lang) +
431 getTrans(' (split HTML)',lang))
432 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
434 getTrans(manual.capitalize(),lang) +
435 getTrans(' (big HTML)',lang))
438 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
439 # TODO: this is an even stupider way of doing it
440 addLang(url+'.pdf', lang),
441 getTrans(manual.capitalize(),lang) + '.pdf')
442 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
443 addLang(url + '/index.html', lang),
444 getTrans(manual.capitalize(),lang) +
445 getTrans(' (split HTML)',lang))
446 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
447 addLang(url + '-big-page.html', lang),
448 getTrans(manual.capitalize(),lang) +
449 getTrans(' (big HTML)',lang))
450 newurl = url + '/index.html'
451 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
452 addLang(newurl, lang),
453 getTrans(manual.capitalize(),lang))
455 def make_regtest_links(name, version, lang):
456 ver_split = version.split('.')
457 ver_minor = ver_split[0] + '.' + ver_split[1]
458 url = depth + "doc/v" + ver_minor + "/input/regression/"
460 make_ver_link(macroLang("regtest"+name, lang),
461 url+"collated-files.html",
462 getTrans("Regression tests for ", lang)+version)
463 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
464 url+"collated-files.pdf",
465 getTrans("PDF of regtests for ", lang)+version)
466 make_ver_link(macroLang("regtest"+name+"Xml", lang),
467 url+"musicxml/collated-files.html",
468 getTrans("MusicXML Regression tests for ", lang)+version)
469 make_ver_link(macroLang("regtest"+name+"Abc", lang),
470 url+"abc2ly/collated-files.html",
471 getTrans("abc2ly Regression tests for ", lang)+version)
472 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
473 url+"lilypond-book/collated-files.html",
474 getTrans("lilypond-book Regression tests for ", lang)+version)
475 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
476 url+"musicxml/collated-files.pdf",
477 getTrans("PDF of MusicXML regtests for ", lang)+version)
478 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
479 url+"abc2ly/collated-files.pdf",
480 getTrans("PDF of abc2ly regtests for ", lang)+version)
481 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
482 url+"lilypond-book/collated-files.pdf",
483 getTrans("PDF of lilypond-book regtests for ", lang)+version)
485 def make_doctarball_links(name, version, lang):
486 url = depth + "download/binaries/documentation/lilypond-"
487 # ugly FIXME, but proper build number support isn't Critical.
488 url += version + "-1"
489 url += ".documentation.tar.bz2"
490 make_ver_link(macroLang("doctarball"+name, lang),
491 url, getTrans("Doc tarball for ", lang)+version)
493 print "@c ************************ Download binaries ************"
494 make_all_downloads("Stable", VERSION_STABLE)
495 make_all_downloads("Devel", VERSION_DEVEL)
497 print "@c ************************ Download source ************"
498 # FIXME: icky hard-coding! -gp
500 print "@c *********", lang, "***"
501 make_download_source("downloadStableSource","v2.14",VERSION_STABLE,lang)
502 make_download_source("downloadDevelSource","v2.15",VERSION_DEVEL,lang)
504 print "@c ************************ Manual links ************"
506 print "@c *********", lang, "***"
507 make_manual_links("Stable", VERSION_STABLE,lang)
508 make_manual_links("Devel", VERSION_DEVEL,lang)
510 make_doctarball_links("Stable", VERSION_STABLE,lang)
511 make_doctarball_links("Devel", VERSION_DEVEL,lang)
513 print "@c ************************ Regtest links ************"
515 print "@c *********", lang, "***"
516 make_regtest_links("Stable", VERSION_STABLE,lang)
517 make_regtest_links("Devel", VERSION_DEVEL,lang)