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, None)
309 # let's not barf, but print a warning when something's missing
310 def getTrans(text, lang):
313 trans = _ (text, lang)
316 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
319 def macroLang(name, lang):
321 return name + '-' + lang
324 def make_macro(name, string):
330 def make_download(name, osA, osB, version, revision, text):
331 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
332 string += osA + "lilypond-"
333 string += version + "-" + revision
334 string += "." + osB + ",\n"
336 string += ": LilyPond "
337 string += version + "-" + revision
339 make_macro(name, string)
341 def make_download_source(name, vstring, version, lang):
342 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
343 string += vstring + "/"
344 string += "lilypond-" + version + ".tar.gz"
346 string += getTrans("Source", lang)
347 string += ": lilypond-" + version + ".tar.gz"
349 make_macro(macroLang(name,lang), string)
351 def make_all_downloads(macroName, version):
352 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
353 "linux-x86.sh", version, "1", "GNU/Linux x86")
354 make_download("download"+macroName+"LinuxBig", "linux-64/",
355 "linux-64.sh", version, "1", "GNU/Linux 64")
356 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
357 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
359 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
360 "freebsd-x86.sh", version, "1", "FreeBSD i386")
361 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
362 "freebsd-64.sh", version, "1", "FreeBSD amd64")
364 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
365 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
366 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
367 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
369 make_download("download"+macroName+"Windows", "mingw/",
370 "mingw.exe", version, "1", "Windows")
372 def make_ver_link(macroname, url, linktext):
378 make_macro(macroname, string)
380 # TODO: this kind of thing should really be in a central place for
381 # lilypond python build scripts
382 def translateNameToUrl(manual, version):
383 ver_split = version.split('.')
384 ver_minor = ver_split[0] + '.' + ver_split[1]
385 url = depth + "doc/v" + ver_minor + "/Documentation/"
387 if (ver_minor == '2.12'):
388 if (manual=='learning'):
389 return url+'user/lilypond-learning'
390 elif (manual=='internals'):
391 return url+'user/lilypond-internals'
392 elif (manual=='notation'):
393 return url+'user/lilypond'
394 elif (manual=='usage'):
395 return url+'user/lilypond-program'
396 elif (manual=='snippets'):
397 return url+'../input/lsr/lilypond-snippets'
398 elif (manual=='changes'):
399 return url+'topdocs/NEWS.html'
400 elif (manual=='music-glossary'):
401 return url+'user/music-glossary'
402 elif (manual=='essay'):
403 return url+'user/lilypond-learning/Background.html'
404 elif (manual=='extending'):
405 return url+'user/lilypond/Interfaces-for-programmers.html'
411 def addLang(url, lang):
413 base, ext = os.path.splitext(url)
414 return base + '.' + lang + ext
418 def make_manual_links(name, version, lang):
419 """Here is where all the macros manualStableLearningSplit,
420 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
421 created on the fly. Hopefully this documentation string will help
422 others a bit while grepping for those.
426 # TODO: this is a stupid way of doing it
427 if (m=='music-glossary'):
430 mshort = m.capitalize()
431 if (manual=='music-glossary'):
432 manual = 'Music glossary'
433 url = translateNameToUrl(m, version)
436 # can't have a comma here due to texinfo
437 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
438 "http://lilypond.org",
439 mshort+getTrans(" (did not exist in 2.12)",lang))
440 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
441 "http://lilypond.org",
442 mshort+getTrans(" (did not exist in 2.12)",lang))
443 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
444 "http://lilypond.org",
445 mshort+getTrans(" (did not exist in 2.12)",lang))
446 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
447 "http://lilypond.org",
448 mshort+getTrans(" (did not exist in 2.12)",lang))
450 # this is stupid and I shouldn't have bothered trying
451 # to support the 2.12 docs and it will be deleted once
452 # 2.14 is out and the website won't be visible to users
453 # until 2.14 is out. -gp
454 if (url.endswith('.html')):
455 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
457 getTrans(manual.capitalize(),lang) + '.pdf')
458 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
460 getTrans(manual.capitalize(),lang) +
461 getTrans(' (split HTML)',lang))
462 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
464 getTrans(manual.capitalize(),lang) +
465 getTrans(' (big HTML)',lang))
468 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
469 # TODO: this is an even stupider way of doing it
470 addLang(url+'.pdf', lang),
471 getTrans(manual.capitalize(),lang) + '.pdf')
472 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
473 addLang(url + '/index.html', lang),
474 getTrans(manual.capitalize(),lang) +
475 getTrans(' (split HTML)',lang))
476 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
477 addLang(url + '-big-page.html', lang),
478 getTrans(manual.capitalize(),lang) +
479 getTrans(' (big HTML)',lang))
480 newurl = url + '/index.html'
481 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
482 addLang(newurl, lang),
483 getTrans(manual.capitalize(),lang))
485 def make_regtest_links(name, version, lang):
486 ver_split = version.split('.')
487 ver_minor = ver_split[0] + '.' + ver_split[1]
488 url = depth + "doc/v" + ver_minor + "/input/regression/"
490 make_ver_link(macroLang("regtest"+name, lang),
491 url+"collated-files.html",
492 getTrans("Regression tests for ", lang)+version)
493 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
494 url+"collated-files.pdf",
495 getTrans("PDF of regtests for ", lang)+version)
496 make_ver_link(macroLang("regtest"+name+"Xml", lang),
497 url+"musicxml/collated-files.html",
498 getTrans("MusicXML Regression tests for ", lang)+version)
499 make_ver_link(macroLang("regtest"+name+"Abc", lang),
500 url+"abc2ly/collated-files.html",
501 getTrans("abc2ly Regression tests for ", lang)+version)
502 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
503 url+"lilypond-book/collated-files.html",
504 getTrans("lilypond-book Regression tests for ", lang)+version)
505 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
506 url+"musicxml/collated-files.pdf",
507 getTrans("PDF of MusicXML regtests for ", lang)+version)
508 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
509 url+"abc2ly/collated-files.pdf",
510 getTrans("PDF of abc2ly regtests for ", lang)+version)
511 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
512 url+"lilypond-book/collated-files.pdf",
513 getTrans("PDF of lilypond-book regtests for ", lang)+version)
515 def make_doctarball_links(name, version, lang):
516 url = depth + "download/binaries/documentation/lilypond-"
517 # ugly FIXME, but proper build number support isn't Critical.
518 url += version + "-1"
519 url += ".documentation.tar.bz2"
520 make_ver_link(macroLang("doctarball"+name, lang),
521 url, getTrans("Doc tarball for ", lang)+version)
523 print "@c ************************ Download binaries ************"
524 make_all_downloads("Stable", VERSION_STABLE)
525 make_all_downloads("Devel", VERSION_DEVEL)
527 print "@c ************************ Download source ************"
528 # FIXME: icky hard-coding! -gp
530 print "@c *********", lang, "***"
531 make_download_source("downloadStableSource","v2.16",VERSION_STABLE,lang)
532 make_download_source("downloadDevelSource","v2.17",VERSION_DEVEL,lang)
534 print "@c ************************ Manual links ************"
536 print "@c *********", lang, "***"
537 make_manual_links("Stable", VERSION_STABLE,lang)
538 make_manual_links("Devel", VERSION_DEVEL,lang)
540 make_doctarball_links("Stable", VERSION_STABLE,lang)
541 make_doctarball_links("Devel", VERSION_DEVEL,lang)
543 print "@c ************************ Regtest links ************"
545 print "@c *********", lang, "***"
546 make_regtest_links("Stable", VERSION_STABLE,lang)
547 make_regtest_links("Devel", VERSION_DEVEL,lang)