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 'abc2ly Regression tests for ': 'abc2ly Regressionstests für ',
62 'PDF of abc2ly regtests for ': 'PDF der abc2ly Regressionstests für ',
63 'lilypond-book Regression tests for ': 'lilypond-book Regressionstests für ',
64 'PDF of lilypond-book regtests for ': 'PDF der lilypond-book Regressionstests für ',
65 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
66 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
68 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
69 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
72 'Source': 'Código fuente',
74 'Learning': 'Aprendizaje',
75 'Music glossary': 'Glosario',
77 'Notation': 'Notación',
78 'Usage': 'Utilización',
79 'Snippets': 'Fragmentos',
82 'Extending': 'Extensión',
83 'Internals': 'Funcionamiento interno',
84 'Contributor': 'Guía del colaborador',
87 ' (split HTML)': ' (HTML seccionado)',
88 ' (big HTML)': ' (HTML monolítico)',
90 'Regression tests for ': 'Pruebas de regresión para ',
91 'PDF of regtests for ': 'Pruebas en PDF para ',
92 'abc2ly Regression tests for ': 'Pruebas de regresión de abc2ly para ',
93 'PDF of abc2ly regtests for ': 'Pruebas de abc2ly en PDF para ',
94 'lilypond-book Regression tests for ': 'Pruebas de regresión de lilypond-book para ',
95 'PDF of lilypond-book regtests for ': 'Pruebas de lilypond-book en PDF para ',
96 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
97 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
99 'Doc tarball for ': 'Tarball de la documentación para ',
100 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
105 'Learning': 'Initiation',
106 'Music glossary': 'Glossaire',
108 'Notation': 'Notation',
109 'Usage': 'Utilisation',
110 'Snippets': 'Morceaux choisis',
112 'Changes': 'Nouveautés',
113 'Extending': 'Extension',
114 'Internals': 'Propriétés internes',
115 'Contributor': 'Guide du contributeur',
118 ' (split HTML)': ' (HTML multipages)',
119 ' (big HTML)': ' (HTML en page unique)',
121 'Regression tests for ': 'Tests de régression pour ',
122 'PDF of regtests for ': 'PDF des tests de régression pour ',
123 'abc2ly Regression tests for ': 'Tests de régression de abc2ly pour ',
124 'PDF of abc2ly regtests for ': 'PDF des tests de régression de abc2ly pour ',
125 'lilypond-book Regression tests for ': 'Tests de régression de lilypond-book pour ',
126 'PDF of lilypond-book regtests for ': 'PDF des tests de régression de lilypond-book pour ',
127 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
128 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
130 'Doc tarball for ': 'Archive de la documentation pour ',
131 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
135 'Learning': 'Tankönyv',
136 'Music glossary': 'Fogalomtár',
138 'Notation': 'Kottaírás',
139 'Usage': 'Használat',
140 'Snippets': 'Kódrészletek',
142 'Changes': 'Változások',
143 'Extending': 'Bővítés',
144 'Internals': 'Belső működés',
145 'Contributor': 'Közreműködés',
147 ' (split HTML)': ' (HTML oldalak)',
148 ' (big HTML)': ' (egy nagy HTML oldal)',
150 'Regression tests for ': 'Regressziós tesztek - verzió: ',
151 'PDF of regtests for ': 'PDF formátumban - verzió: ',
152 'abc2ly Regression tests for ': 'abc2ly regressziós tesztek - verzió: ',
153 'PDF of abc2ly regtests for ': 'PDF formátumban - verzió: ',
154 'lilypond-book Regression tests for ': 'lilypond-book regressziós tesztek - verzió: ',
155 'PDF of lilypond-book regtests for ': 'PDF formátumban - verzió: ',
156 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
157 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
159 'Doc tarball for ': 'Tömörített csomag - verzió: ',
160 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
165 'Music glossary': '用語集',
169 'Snippets': 'コード断片集',
175 'Internals': '内部リファレンス',
176 'Contributor': '貢献者向けガイド',
179 ' (split HTML)': ' (ページ毎に分割された HTML)',
180 ' (big HTML)': ' (1 つの大きな HTML)',
182 'Regression tests for ': '回帰テスト バージョン ',
183 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
184 'abc2ly Regression tests for ': 'abc2ly 回帰テスト バージョン ',
185 'PDF of abc2ly regtests for ': 'abc2ly 回帰テスト (PDF 版) バージョン ',
186 'lilypond-book Regression tests for ': 'lilypond-book 回帰テスト バージョン ',
187 'PDF of lilypond-book regtests for ': 'lilypond-book 回帰テスト (PDF 版) バージョン ',
188 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
189 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
191 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
192 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
196 'Source': 'Broncode',
198 'Learning': 'Beginnen',
199 'Music glossary': 'Terminologie',
201 'Notation': 'Notatie',
203 'Snippets': 'Snippers',
205 'Changes': 'Veranderingen',
206 'Extending': 'Uitbreidingen',
207 'Internals': 'Internals',
208 'Contributor': 'Contributor',
211 ' (split HTML)': ' (opgesplitste HTML)',
212 ' (big HTML)': ' (grote pagina HTML)',
214 'Regression tests for ': 'Regressietesten voor ',
215 'PDF of regtests for ': 'PDF van regressietesten voor ',
216 'abc2ly Regression tests for ': 'abc2ly regressietesten voor ',
217 'PDF of abc2ly regtests for ': 'abc2ly regressietesten voor ',
218 'lilypond-book Regression tests for ': 'lilypond-book regressietesten voor ',
219 'PDF of lilypond-book regtests for ': 'lilypond-book regressietesten voor ',
220 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
221 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
223 'Doc tarball for ': 'Tarball met documentation voor ',
224 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
229 'Music glossary': '音乐术语表',
239 'Contributor': '贡献者',
242 ' (split HTML)': ' (分开的 HTML)',
243 ' (big HTML)': ' (大的 HTML)',
245 'Regression tests for ': '回归测试 ',
246 'PDF of regtests for ': '回归测试的 PDF ',
247 'abc2ly Regression tests for ': 'abc2ly 回归测试 ',
248 'PDF of abc2ly regtests for ': 'abc2ly 的 PDF 回归测试 ',
249 'lilypond-book Regression tests for ': 'lilypond-book 回归测试 ',
250 'PDF of lilypond-book regtests for ': 'lilypond-book 的 PDF 回归测试 ',
251 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
252 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
254 'Doc tarball for ': '为文档压缩包',
255 ' (did not exist in 2.12)': ' (在 2.12 中不存在)',
271 myDir = os.path.dirname(sys.argv[0])
272 # use two abspaths to work around some windows python bug
273 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
274 topDir = os.path.abspath( topDir )
277 # TODO: this might be useful for other scripts; can we make it available?
278 manuals = map(lambda x: os.path.splitext(x)[0],
279 map(os.path.basename,
280 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
281 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
282 manuals.append('internals')
285 version_file_path = os.path.join(topDir, "VERSION")
287 version_contents = open(version_file_path).readlines()
291 for line in version_contents:
292 if (line.startswith('MAJOR_VERSION')):
294 if (line.startswith('MINOR_VERSION')):
296 if (line.startswith('PATCH_LEVEL')):
298 if (line.startswith('VERSION_STABLE')):
299 VERSION_STABLE = line[15:-1]
300 if (line.startswith('VERSION_DEVEL')):
301 VERSION_DEVEL = line[14:-1]
303 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
305 def _ (string, lang):
306 return translations.get (lang.split ('_')[0], {}).get (string, string)
309 # let's not barf, but print a warning when something's missing
310 def getTrans(text, lang):
311 trans = _ (text, lang)
314 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
317 def macroLang(name, lang):
319 return name + '-' + lang
322 def make_macro(name, string):
328 def make_download(name, osA, osB, version, revision, text):
329 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
330 string += osA + "lilypond-"
331 string += version + "-" + revision
332 string += "." + osB + ",\n"
334 string += ": LilyPond "
335 string += version + "-" + revision
337 make_macro(name, string)
339 def make_download_source(name, vstring, version, lang):
340 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
341 string += vstring + "/"
342 string += "lilypond-" + version + ".tar.gz"
344 string += getTrans("Source", lang)
345 string += ": lilypond-" + version + ".tar.gz"
347 make_macro(macroLang(name,lang), string)
349 def make_all_downloads(macroName, version):
350 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
351 "linux-x86.sh", version, "1", "GNU/Linux x86")
352 make_download("download"+macroName+"LinuxBig", "linux-64/",
353 "linux-64.sh", version, "1", "GNU/Linux 64")
354 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
355 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
357 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
358 "freebsd-x86.sh", version, "1", "FreeBSD i386")
359 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
360 "freebsd-64.sh", version, "1", "FreeBSD amd64")
362 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
363 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
364 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
365 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
367 make_download("download"+macroName+"Windows", "mingw/",
368 "mingw.exe", version, "1", "Windows")
370 def make_ver_link(macroname, url, linktext):
376 make_macro(macroname, string)
378 # TODO: this kind of thing should really be in a central place for
379 # lilypond python build scripts
380 def translateNameToUrl(manual, version):
381 ver_split = version.split('.')
382 ver_minor = ver_split[0] + '.' + ver_split[1]
383 url = depth + "doc/v" + ver_minor + "/Documentation/"
385 if (ver_minor == '2.12'):
386 if (manual=='learning'):
387 return url+'user/lilypond-learning'
388 elif (manual=='internals'):
389 return url+'user/lilypond-internals'
390 elif (manual=='notation'):
391 return url+'user/lilypond'
392 elif (manual=='usage'):
393 return url+'user/lilypond-program'
394 elif (manual=='snippets'):
395 return url+'../input/lsr/lilypond-snippets'
396 elif (manual=='changes'):
397 return url+'topdocs/NEWS.html'
398 elif (manual=='music-glossary'):
399 return url+'user/music-glossary'
400 elif (manual=='essay'):
401 return url+'user/lilypond-learning/Background.html'
402 elif (manual=='extending'):
403 return url+'user/lilypond/Interfaces-for-programmers.html'
409 def addLang(url, lang):
411 base, ext = os.path.splitext(url)
412 return base + '.' + lang + ext
416 def make_manual_links(name, version, lang):
417 """Here is where all the macros manualStableLearningSplit,
418 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
419 created on the fly. Hopefully this documentation string will help
420 others a bit while grepping for those.
424 # TODO: this is a stupid way of doing it
425 if (m=='music-glossary'):
428 mshort = m.capitalize()
429 if (manual=='music-glossary'):
430 manual = 'Music glossary'
431 url = translateNameToUrl(m, version)
434 # can't have a comma here due to texinfo
435 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
436 "http://lilypond.org",
437 mshort+getTrans(" (did not exist in 2.12)",lang))
438 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
439 "http://lilypond.org",
440 mshort+getTrans(" (did not exist in 2.12)",lang))
441 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
442 "http://lilypond.org",
443 mshort+getTrans(" (did not exist in 2.12)",lang))
444 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
445 "http://lilypond.org",
446 mshort+getTrans(" (did not exist in 2.12)",lang))
448 # this is stupid and I shouldn't have bothered trying
449 # to support the 2.12 docs and it will be deleted once
450 # 2.14 is out and the website won't be visible to users
451 # until 2.14 is out. -gp
452 if (url.endswith('.html')):
453 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
455 getTrans(manual.capitalize(),lang) + '.pdf')
456 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
458 getTrans(manual.capitalize(),lang) +
459 getTrans(' (split HTML)',lang))
460 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
462 getTrans(manual.capitalize(),lang) +
463 getTrans(' (big HTML)',lang))
466 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
467 # TODO: this is an even stupider way of doing it
468 addLang(url+'.pdf', lang),
469 getTrans(manual.capitalize(),lang) + '.pdf')
470 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
471 addLang(url + '/index.html', lang),
472 getTrans(manual.capitalize(),lang) +
473 getTrans(' (split HTML)',lang))
474 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
475 addLang(url + '-big-page.html', lang),
476 getTrans(manual.capitalize(),lang) +
477 getTrans(' (big HTML)',lang))
478 newurl = url + '/index.html'
479 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
480 addLang(newurl, lang),
481 getTrans(manual.capitalize(),lang))
483 def make_regtest_links(name, version, lang):
484 ver_split = version.split('.')
485 ver_minor = ver_split[0] + '.' + ver_split[1]
486 url = depth + "doc/v" + ver_minor + "/input/regression/"
488 make_ver_link(macroLang("regtest"+name, lang),
489 url+"collated-files.html",
490 getTrans("Regression tests for ", lang)+version)
491 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
492 url+"collated-files.pdf",
493 getTrans("PDF of regtests for ", lang)+version)
494 make_ver_link(macroLang("regtest"+name+"Xml", lang),
495 url+"musicxml/collated-files.html",
496 getTrans("MusicXML Regression tests for ", lang)+version)
497 make_ver_link(macroLang("regtest"+name+"Abc", lang),
498 url+"abc2ly/collated-files.html",
499 getTrans("abc2ly Regression tests for ", lang)+version)
500 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
501 url+"lilypond-book/collated-files.html",
502 getTrans("lilypond-book Regression tests for ", lang)+version)
503 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
504 url+"musicxml/collated-files.pdf",
505 getTrans("PDF of MusicXML regtests for ", lang)+version)
506 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
507 url+"abc2ly/collated-files.pdf",
508 getTrans("PDF of abc2ly regtests for ", lang)+version)
509 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
510 url+"lilypond-book/collated-files.pdf",
511 getTrans("PDF of lilypond-book regtests for ", lang)+version)
513 def make_doctarball_links(name, version, lang):
514 url = depth + "download/binaries/documentation/lilypond-"
515 # ugly FIXME, but proper build number support isn't Critical.
516 url += version + "-1"
517 url += ".documentation.tar.bz2"
518 make_ver_link(macroLang("doctarball"+name, lang),
519 url, getTrans("Doc tarball for ", lang)+version)
521 print "@c ************************ Download binaries ************"
522 make_all_downloads("Stable", VERSION_STABLE)
523 make_all_downloads("Devel", VERSION_DEVEL)
525 print "@c ************************ Download source ************"
526 # FIXME: icky hard-coding! -gp
528 print "@c *********", lang, "***"
529 make_download_source("downloadStableSource","v2.16",VERSION_STABLE,lang)
530 make_download_source("downloadDevelSource","v2.17",VERSION_DEVEL,lang)
532 print "@c ************************ Manual links ************"
534 print "@c *********", lang, "***"
535 make_manual_links("Stable", VERSION_STABLE,lang)
536 make_manual_links("Devel", VERSION_DEVEL,lang)
538 make_doctarball_links("Stable", VERSION_STABLE,lang)
539 make_doctarball_links("Devel", VERSION_DEVEL,lang)
541 print "@c ************************ Regtest links ************"
543 print "@c *********", lang, "***"
544 make_regtest_links("Stable", VERSION_STABLE,lang)
545 make_regtest_links("Devel", VERSION_DEVEL,lang)