2 # -*- coding: utf-8 -*-
3 # create-weblinks-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'
44 'Music glossary': 'Slovníček',
46 'Notation': 'Notový zápis',
52 'Extending': 'Rozšíření',
53 'Internals': 'Vnitřnosti',
54 'Contributor': 'Vývojářské',
56 ' (split HTML)': ' (rozdělené HTML)',
57 ' (big HTML)': ' (velké HTML)',
59 'Regression tests for ': 'Zkoušky regresí ',
60 'PDF of regtests for ': 'PDF zkoušky regresí ',
61 'abc2ly Regression tests for ': 'abc2ly zkoušky regresí ',
62 'PDF of abc2ly regtests for ': 'PDF abc2ly zkoušky regresí ',
63 'lilypond-book Regression tests for ': 'lilypond-book zkoušky regresí ',
64 'PDF of lilypond-book regtests for ': 'PDF lilypond-book zkoušky regresí ',
65 'MusicXML Regression tests for ': 'MusicXML zkoušky regresí ',
66 'PDF of MusicXML regtests for ': 'PDF MusicXML zkoušky regresí ',
68 'Doc tarball for ': 'Doc tarball for ',
72 'Learning': 'Einführung',
73 'Music glossary': 'Glossar',
75 'Notation': 'Notation',
77 'Snippets': 'Schnipsel',
79 'Changes': 'Änderungen',
81 'Extending': 'Erweitern',
82 'Internals': 'Interna',
83 'Contributor': 'Beitragen',
85 ' (split HTML)': ' (geteiltes HTML)',
86 ' (big HTML)': ' (großes HTML)',
88 'Regression tests for ': 'Regressionstests für ',
89 'PDF of regtests for ': 'PDF der Regressionstests für ',
90 'abc2ly Regression tests for ': 'abc2ly Regressionstests für ',
91 'PDF of abc2ly regtests for ': 'PDF der abc2ly Regressionstests für ',
92 'lilypond-book Regression tests for ': 'lilypond-book Regressionstests für ',
93 'PDF of lilypond-book regtests for ': 'PDF der lilypond-book Regressionstests für ',
94 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
95 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
97 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
100 'Source': 'Código fuente',
102 'Learning': 'Aprendizaje',
103 'Music glossary': 'Glosario',
105 'Notation': 'Notación',
106 'Usage': 'Utilización',
107 'Snippets': 'Fragmentos',
109 'Changes': 'Cambios',
110 'Extending': 'Extensión',
111 'Internals': 'Funcionamiento interno',
112 'Contributor': 'Guía del colaborador',
115 ' (split HTML)': ' (HTML seccionado)',
116 ' (big HTML)': ' (HTML monolítico)',
118 'Regression tests for ': 'Pruebas de regresión para ',
119 'PDF of regtests for ': 'Pruebas en PDF para ',
120 'abc2ly Regression tests for ': 'Pruebas de regresión de abc2ly para ',
121 'PDF of abc2ly regtests for ': 'Pruebas de abc2ly en PDF para ',
122 'lilypond-book Regression tests for ': 'Pruebas de regresión de lilypond-book para ',
123 'PDF of lilypond-book regtests for ': 'Pruebas de lilypond-book en PDF para ',
124 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
125 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
127 'Doc tarball for ': 'Tarball de la documentación para ',
132 'Learning': 'Initiation',
133 'Music glossary': 'Glossaire',
135 'Notation': 'Notation',
136 'Usage': 'Utilisation',
137 'Snippets': 'Morceaux choisis',
139 'Changes': 'Nouveautés',
140 'Extending': 'Extension',
141 'Internals': 'Propriétés internes',
142 'Contributor': 'Guide du contributeur',
145 ' (split HTML)': ' (HTML multipages)',
146 ' (big HTML)': ' (HTML en page unique)',
148 'Regression tests for ': 'Tests de régression pour ',
149 'PDF of regtests for ': 'PDF des tests de régression pour ',
150 'abc2ly Regression tests for ': 'Tests de régression de abc2ly pour ',
151 'PDF of abc2ly regtests for ': 'PDF des tests de régression de abc2ly pour ',
152 'lilypond-book Regression tests for ': 'Tests de régression de lilypond-book pour ',
153 'PDF of lilypond-book regtests for ': 'PDF des tests de régression de lilypond-book pour ',
154 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
155 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
157 'Doc tarball for ': 'Archive de la documentation pour ',
161 'Learning': 'Tankönyv',
162 'Music glossary': 'Fogalomtár',
164 'Notation': 'Kottaírás',
165 'Usage': 'Használat',
166 'Snippets': 'Kódrészletek',
168 'Changes': 'Változások',
169 'Extending': 'Bővítés',
170 'Internals': 'Belső működés',
171 'Contributor': 'Közreműködés',
173 ' (split HTML)': ' (HTML oldalak)',
174 ' (big HTML)': ' (egy nagy HTML oldal)',
176 'Regression tests for ': 'Regressziós tesztek - verzió: ',
177 'PDF of regtests for ': 'PDF formátumban - verzió: ',
178 'abc2ly Regression tests for ': 'abc2ly regressziós tesztek - verzió: ',
179 'PDF of abc2ly regtests for ': 'PDF formátumban - verzió: ',
180 'lilypond-book Regression tests for ': 'lilypond-book regressziós tesztek - verzió: ',
181 'PDF of lilypond-book regtests for ': 'PDF formátumban - verzió: ',
182 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
183 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
185 'Doc tarball for ': 'Tömörített csomag - verzió: ',
188 'Source': 'Sorgenti',
189 'Learning': 'Apprendimento',
190 'Music glossary': 'Glossario',
192 'Notation': 'Notazione',
194 'Snippets': 'Frammenti',
196 'Changes': 'Cambiamenti',
197 'Extending': 'Estendere',
198 'Internals': 'Funzionamento interno',
199 'Contributor': 'Guida del collaboratore',
202 ' (split HTML)': ' (HTML multipagina)',
203 ' (big HTML)': ' (HTML pagina unica)',
205 'Regression tests for ': 'Test di collaudo per ',
206 'PDF of regtests for ': 'PDF dei test di collaudo per ',
207 'abc2ly Regression tests for ': 'Test di collaudo di abc2ly per ',
208 'PDF of abc2ly regtests for ': 'PDF dei test di collaudo di abc2ly per ',
209 'lilypond-book Regression tests for ': 'Test di collaudo di lilypond-book per ',
210 'PDF of lilypond-book regtests for ': 'PDF dei test di collaudo di lilypond-book per ',
211 'MusicXML Regression tests for ': 'Test di collaudo di MusicXML per ',
212 'PDF of MusicXML regtests for ': 'PDF dei test di collaudo di MusicXML per ',
214 'Doc tarball for ': 'Archivio della documentazione per ',
219 'Music glossary': '用語集',
223 'Snippets': 'コード断片集',
229 'Internals': '内部リファレンス',
230 'Contributor': '貢献者向けガイド',
233 ' (split HTML)': ' (ページ毎に分割された HTML)',
234 ' (big HTML)': ' (1 つの大きな HTML)',
236 'Regression tests for ': '回帰テスト バージョン ',
237 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
238 'abc2ly Regression tests for ': 'abc2ly 回帰テスト バージョン ',
239 'PDF of abc2ly regtests for ': 'abc2ly 回帰テスト (PDF 版) バージョン ',
240 'lilypond-book Regression tests for ': 'lilypond-book 回帰テスト バージョン ',
241 'PDF of lilypond-book regtests for ': 'lilypond-book 回帰テスト (PDF 版) バージョン ',
242 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
243 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
245 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
249 'Source': 'Broncode',
251 'Learning': 'Beginnen',
252 'Music glossary': 'Terminologie',
254 'Notation': 'Notatie',
256 'Snippets': 'Snippers',
258 'Changes': 'Veranderingen',
259 'Extending': 'Uitbreidingen',
260 'Internals': 'Internals',
261 'Contributor': 'Contributor',
264 ' (split HTML)': ' (opgesplitste HTML)',
265 ' (big HTML)': ' (grote pagina HTML)',
267 'Regression tests for ': 'Regressietesten voor ',
268 'PDF of regtests for ': 'PDF van regressietesten voor ',
269 'abc2ly Regression tests for ': 'abc2ly regressietesten voor ',
270 'PDF of abc2ly regtests for ': 'abc2ly regressietesten voor ',
271 'lilypond-book Regression tests for ': 'lilypond-book regressietesten voor ',
272 'PDF of lilypond-book regtests for ': 'lilypond-book regressietesten voor ',
273 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
274 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
276 'Doc tarball for ': 'Tarball met documentation voor ',
281 'Music glossary': '音乐术语表',
291 'Contributor': '贡献者',
294 ' (split HTML)': ' (分开的 HTML)',
295 ' (big HTML)': ' (大的 HTML)',
297 'Regression tests for ': '回归测试 ',
298 'PDF of regtests for ': '回归测试的 PDF ',
299 'abc2ly Regression tests for ': 'abc2ly 回归测试 ',
300 'PDF of abc2ly regtests for ': 'abc2ly 的 PDF 回归测试 ',
301 'lilypond-book Regression tests for ': 'lilypond-book 回归测试 ',
302 'PDF of lilypond-book regtests for ': 'lilypond-book 的 PDF 回归测试 ',
303 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
304 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
306 'Doc tarball for ': '为文档压缩包',
322 myDir = os.path.dirname(sys.argv[0])
323 # use two abspaths to work around some windows python bug
324 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
325 topDir = os.path.abspath( topDir )
328 # TODO: this might be useful for other scripts; can we make it available?
329 manuals = map(lambda x: os.path.splitext(x)[0],
330 map(os.path.basename,
331 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
332 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
333 manuals.append('internals')
336 version_file_path = os.path.join(topDir, "VERSION")
338 version_contents = open(version_file_path).readlines()
342 for line in version_contents:
343 if (line.startswith('MAJOR_VERSION')):
345 if (line.startswith('MINOR_VERSION')):
347 if (line.startswith('PATCH_LEVEL')):
349 if (line.startswith('VERSION_STABLE')):
350 VERSION_STABLE = line[15:-1]
351 if (line.startswith('VERSION_DEVEL')):
352 VERSION_DEVEL = line[14:-1]
354 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
356 def _ (string, lang):
357 return translations.get (lang.split ('_')[0], {}).get (string, None)
360 # let's not barf, but print a warning when something's missing
361 def getTrans(text, lang):
364 trans = _ (text, lang)
367 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
370 def macroLang(name, lang):
372 return name + '-' + lang
375 def make_macro(name, string):
381 def make_download(name, osA, osB, version, revision, text):
382 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
383 string += osA + "lilypond-"
384 string += version + "-" + revision
385 string += "." + osB + ",\n"
387 string += ": LilyPond "
388 string += version + "-" + revision
390 make_macro(name, string)
392 def make_download_source(name, version, lang):
393 assert "." in version
394 vstring = "v%s.%s" % tuple(version.split(".", 2)[0:2])
395 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
396 string += vstring + "/"
397 string += "lilypond-" + version + ".tar.gz"
399 string += getTrans("Source", lang)
400 string += ": lilypond-" + version + ".tar.gz"
402 make_macro(macroLang(name,lang), string)
404 def make_all_downloads(macroName, version):
405 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
406 "linux-x86.sh", version, "1", "GNU/Linux x86")
407 make_download("download"+macroName+"LinuxBig", "linux-64/",
408 "linux-64.sh", version, "1", "GNU/Linux 64")
409 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
410 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
412 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
413 "freebsd-x86.sh", version, "1", "FreeBSD i386")
414 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
415 "freebsd-64.sh", version, "1", "FreeBSD amd64")
417 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
418 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
419 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
420 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
422 make_download("download"+macroName+"Windows", "mingw/",
423 "mingw.exe", version, "1", "Windows")
425 def make_ver_link(macroname, url, linktext):
431 make_macro(macroname, string)
433 # TODO: this kind of thing should really be in a central place for
434 # lilypond python build scripts
435 def translateNameToUrl(manual, version):
436 ver_split = version.split('.')
437 ver_minor = ver_split[0] + '.' + ver_split[1]
438 url = depth + "doc/v" + ver_minor + "/Documentation/"
442 def addLang(url, lang):
444 base, ext = os.path.splitext(url)
445 return base + '.' + lang + ext
449 def make_manual_links(name, version, lang):
450 """Here is where all the macros manualStableLearningSplit,
451 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
452 created on the fly. Hopefully this documentation string will help
453 others a bit while grepping for those.
457 # TODO: this is a stupid way of doing it
458 if (m=='music-glossary'):
461 mshort = m.capitalize()
462 if (manual=='music-glossary'):
463 manual = 'Music glossary'
464 url = translateNameToUrl(m, version)
466 if (url.endswith('.html')):
467 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
469 getTrans(manual.capitalize(),lang) + '.pdf')
470 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
472 getTrans(manual.capitalize(),lang) +
473 getTrans(' (split HTML)',lang))
474 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
476 getTrans(manual.capitalize(),lang) +
477 getTrans(' (big HTML)',lang))
480 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
481 # TODO: this is an even stupider way of doing it
482 addLang(url+'.pdf', lang),
483 getTrans(manual.capitalize(),lang) + '.pdf')
484 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
485 addLang(url + '/index.html', lang),
486 getTrans(manual.capitalize(),lang) +
487 getTrans(' (split HTML)',lang))
488 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
489 addLang(url + '-big-page.html', lang),
490 getTrans(manual.capitalize(),lang) +
491 getTrans(' (big HTML)',lang))
492 newurl = url + '/index.html'
493 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
494 addLang(newurl, lang),
495 getTrans(manual.capitalize(),lang))
497 def make_regtest_links(name, version, lang):
498 ver_split = version.split('.')
499 ver_minor = ver_split[0] + '.' + ver_split[1]
500 url = depth + "doc/v" + ver_minor + "/input/regression/"
502 make_ver_link(macroLang("regtest"+name, lang),
503 url+"collated-files.html",
504 getTrans("Regression tests for ", lang)+version)
505 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
506 url+"collated-files.pdf",
507 getTrans("PDF of regtests for ", lang)+version)
508 make_ver_link(macroLang("regtest"+name+"Xml", lang),
509 url+"musicxml/collated-files.html",
510 getTrans("MusicXML Regression tests for ", lang)+version)
511 make_ver_link(macroLang("regtest"+name+"Abc", lang),
512 url+"abc2ly/collated-files.html",
513 getTrans("abc2ly Regression tests for ", lang)+version)
514 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
515 url+"lilypond-book/collated-files.html",
516 getTrans("lilypond-book Regression tests for ", lang)+version)
517 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
518 url+"musicxml/collated-files.pdf",
519 getTrans("PDF of MusicXML regtests for ", lang)+version)
520 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
521 url+"abc2ly/collated-files.pdf",
522 getTrans("PDF of abc2ly regtests for ", lang)+version)
523 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
524 url+"lilypond-book/collated-files.pdf",
525 getTrans("PDF of lilypond-book regtests for ", lang)+version)
527 def make_doctarball_links(name, version, lang):
528 url = depth + "download/binaries/documentation/lilypond-"
529 # ugly FIXME, but proper build number support isn't Critical.
530 url += version + "-1"
531 url += ".documentation.tar.bz2"
532 make_ver_link(macroLang("doctarball"+name, lang),
533 url, getTrans("Doc tarball for ", lang)+version)
535 print "@c This file was autogenerated"
536 print "@c from: %s" % VERSION
537 print "@c by: %s" % sys.argv[0]
539 print "@c ************************ Download binaries ************"
542 make_all_downloads("Stable", VERSION_STABLE)
543 make_all_downloads("Devel", VERSION_DEVEL)
545 print "@c ************************ Download source ************"
549 print "@c *********", lang or "en", "***"
550 make_download_source("downloadStableSource", VERSION_STABLE, lang)
551 make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
553 print "@c ************************ Manual links ************"
557 print "@c *********", lang or "en", "***"
558 make_manual_links("Stable", VERSION_STABLE, lang)
559 make_manual_links("Devel", VERSION_DEVEL, lang)
561 make_doctarball_links("Stable", VERSION_STABLE, lang)
562 make_doctarball_links("Devel", VERSION_DEVEL, lang)
564 print "@c ************************ Regtest links ************"
568 print "@c *********", lang or "en", "***"
569 make_regtest_links("Stable", VERSION_STABLE, lang)
570 make_regtest_links("Devel", VERSION_DEVEL, lang)
571 print "@c ***************************************************"