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 ca 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': 'Aprenentatge',
44 'Music glossary': 'Glossari musical',
45 'Essay': 'Monografia',
46 'Notation': 'Notació',
48 'Snippets': 'Fragments',
52 'Extending': 'Extensions',
53 'Internals': 'Funcionament intern',
54 'Contributor': 'Guia del col·laborador',
56 ' (split HTML)': ' (HTML seccionat)',
57 ' (big HTML)': ' (HTML monolític)',
59 'Regression tests for ': 'Proves de regressió per a ',
60 'PDF of regtests for ': 'Proves de regressió en PDF per a ',
61 'abc2ly Regression tests for ': 'Proves de regressió d\'abc2ly per a ',
62 'PDF of abc2ly regtests for ': 'Proves de regressió d\'abc2ly en PDF per a ',
63 'lilypond-book Regression tests for ': 'Proves de regressió de lilypond-book per a ',
64 'PDF of lilypond-book regtests for ': 'Proves de regressió de lilypond-book en PDF per a ',
65 'MusicXML Regression tests for ': 'Proves de regressió de MusicXML per a ',
66 'PDF of MusicXML regtests for ': 'Proves de regressió de MusicXML en PDF per a ',
68 'Doc tarball for ': 'Tarball de la documentació per a ',
73 'Music glossary': 'Slovníček',
75 'Notation': 'Notový zápis',
81 'Extending': 'Rozšíření',
82 'Internals': 'Vnitřnosti',
83 'Contributor': 'Vývojářské',
85 ' (split HTML)': ' (rozdělené HTML)',
86 ' (big HTML)': ' (velké HTML)',
88 'Regression tests for ': 'Zkoušky regresí ',
89 'PDF of regtests for ': 'PDF zkoušky regresí ',
90 'abc2ly Regression tests for ': 'abc2ly zkoušky regresí ',
91 'PDF of abc2ly regtests for ': 'PDF abc2ly zkoušky regresí ',
92 'lilypond-book Regression tests for ': 'lilypond-book zkoušky regresí ',
93 'PDF of lilypond-book regtests for ': 'PDF lilypond-book zkoušky regresí ',
94 'MusicXML Regression tests for ': 'MusicXML zkoušky regresí ',
95 'PDF of MusicXML regtests for ': 'PDF MusicXML zkoušky regresí ',
97 'Doc tarball for ': 'Doc tarball for ',
101 'Learning': 'Einführung',
102 'Music glossary': 'Glossar',
104 'Notation': 'Notation',
105 'Usage': 'Benutzung',
106 'Snippets': 'Schnipsel',
108 'Changes': 'Änderungen',
110 'Extending': 'Erweitern',
111 'Internals': 'Interna',
112 'Contributor': 'Beitragen',
114 ' (split HTML)': ' (geteiltes HTML)',
115 ' (big HTML)': ' (großes HTML)',
117 'Regression tests for ': 'Regressionstests für ',
118 'PDF of regtests for ': 'PDF der Regressionstests für ',
119 'abc2ly Regression tests for ': 'abc2ly Regressionstests für ',
120 'PDF of abc2ly regtests for ': 'PDF der abc2ly Regressionstests für ',
121 'lilypond-book Regression tests for ': 'lilypond-book Regressionstests für ',
122 'PDF of lilypond-book regtests for ': 'PDF der lilypond-book Regressionstests für ',
123 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
124 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
126 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
129 'Source': 'Código fuente',
131 'Learning': 'Aprendizaje',
132 'Music glossary': 'Glosario',
134 'Notation': 'Notación',
135 'Usage': 'Utilización',
136 'Snippets': 'Fragmentos',
138 'Changes': 'Cambios',
139 'Extending': 'Extensión',
140 'Internals': 'Funcionamiento interno',
141 'Contributor': 'Guía del colaborador',
144 ' (split HTML)': ' (HTML seccionado)',
145 ' (big HTML)': ' (HTML monolítico)',
147 'Regression tests for ': 'Pruebas de regresión para ',
148 'PDF of regtests for ': 'Pruebas en PDF para ',
149 'abc2ly Regression tests for ': 'Pruebas de regresión de abc2ly para ',
150 'PDF of abc2ly regtests for ': 'Pruebas de abc2ly en PDF para ',
151 'lilypond-book Regression tests for ': 'Pruebas de regresión de lilypond-book para ',
152 'PDF of lilypond-book regtests for ': 'Pruebas de lilypond-book en PDF para ',
153 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
154 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
156 'Doc tarball for ': 'Tarball de la documentación para ',
161 'Learning': 'Initiation',
162 'Music glossary': 'Glossaire',
164 'Notation': 'Notation',
165 'Usage': 'Utilisation',
166 'Snippets': 'Morceaux choisis',
168 'Changes': 'Nouveautés',
169 'Extending': 'Extension',
170 'Internals': 'Propriétés internes',
171 'Contributor': 'Guide du contributeur',
174 ' (split HTML)': ' (HTML multipages)',
175 ' (big HTML)': ' (HTML en page unique)',
177 'Regression tests for ': 'Tests de régression pour ',
178 'PDF of regtests for ': 'PDF des tests de régression pour ',
179 'abc2ly Regression tests for ': 'Tests de régression de abc2ly pour ',
180 'PDF of abc2ly regtests for ': 'PDF des tests de régression de abc2ly pour ',
181 'lilypond-book Regression tests for ': 'Tests de régression de lilypond-book pour ',
182 'PDF of lilypond-book regtests for ': 'PDF des tests de régression de lilypond-book pour ',
183 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
184 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
186 'Doc tarball for ': 'Archive de la documentation pour ',
190 'Learning': 'Tankönyv',
191 'Music glossary': 'Fogalomtár',
193 'Notation': 'Kottaírás',
194 'Usage': 'Használat',
195 'Snippets': 'Kódrészletek',
197 'Changes': 'Változások',
198 'Extending': 'Bővítés',
199 'Internals': 'Belső működés',
200 'Contributor': 'Közreműködés',
202 ' (split HTML)': ' (HTML oldalak)',
203 ' (big HTML)': ' (egy nagy HTML oldal)',
205 'Regression tests for ': 'Regressziós tesztek - verzió: ',
206 'PDF of regtests for ': 'PDF formátumban - verzió: ',
207 'abc2ly Regression tests for ': 'abc2ly regressziós tesztek - verzió: ',
208 'PDF of abc2ly regtests for ': 'PDF formátumban - verzió: ',
209 'lilypond-book Regression tests for ': 'lilypond-book regressziós tesztek - verzió: ',
210 'PDF of lilypond-book regtests for ': 'PDF formátumban - verzió: ',
211 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
212 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
214 'Doc tarball for ': 'Tömörített csomag - verzió: ',
217 'Source': 'Sorgenti',
218 'Learning': 'Apprendimento',
219 'Music glossary': 'Glossario',
221 'Notation': 'Notazione',
223 'Snippets': 'Frammenti',
225 'Changes': 'Cambiamenti',
226 'Extending': 'Estendere',
227 'Internals': 'Funzionamento interno',
228 'Contributor': 'Guida del collaboratore',
231 ' (split HTML)': ' (HTML multipagina)',
232 ' (big HTML)': ' (HTML pagina unica)',
234 'Regression tests for ': 'Test di collaudo per ',
235 'PDF of regtests for ': 'PDF dei test di collaudo per ',
236 'abc2ly Regression tests for ': 'Test di collaudo di abc2ly per ',
237 'PDF of abc2ly regtests for ': 'PDF dei test di collaudo di abc2ly per ',
238 'lilypond-book Regression tests for ': 'Test di collaudo di lilypond-book per ',
239 'PDF of lilypond-book regtests for ': 'PDF dei test di collaudo di lilypond-book per ',
240 'MusicXML Regression tests for ': 'Test di collaudo di MusicXML per ',
241 'PDF of MusicXML regtests for ': 'PDF dei test di collaudo di MusicXML per ',
243 'Doc tarball for ': 'Archivio della documentazione per ',
248 'Music glossary': '用語集',
252 'Snippets': 'コード断片集',
258 'Internals': '内部リファレンス',
259 'Contributor': '貢献者向けガイド',
262 ' (split HTML)': ' (ページ毎に分割された HTML)',
263 ' (big HTML)': ' (1 つの大きな HTML)',
265 'Regression tests for ': '回帰テスト バージョン ',
266 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
267 'abc2ly Regression tests for ': 'abc2ly 回帰テスト バージョン ',
268 'PDF of abc2ly regtests for ': 'abc2ly 回帰テスト (PDF 版) バージョン ',
269 'lilypond-book Regression tests for ': 'lilypond-book 回帰テスト バージョン ',
270 'PDF of lilypond-book regtests for ': 'lilypond-book 回帰テスト (PDF 版) バージョン ',
271 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
272 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
274 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
278 'Source': 'Broncode',
280 'Learning': 'Beginnen',
281 'Music glossary': 'Terminologie',
283 'Notation': 'Notatie',
285 'Snippets': 'Snippers',
287 'Changes': 'Veranderingen',
288 'Extending': 'Uitbreidingen',
289 'Internals': 'Internals',
290 'Contributor': 'Contributor',
293 ' (split HTML)': ' (opgesplitste HTML)',
294 ' (big HTML)': ' (grote pagina HTML)',
296 'Regression tests for ': 'Regressietesten voor ',
297 'PDF of regtests for ': 'PDF van regressietesten voor ',
298 'abc2ly Regression tests for ': 'abc2ly regressietesten voor ',
299 'PDF of abc2ly regtests for ': 'abc2ly regressietesten voor ',
300 'lilypond-book Regression tests for ': 'lilypond-book regressietesten voor ',
301 'PDF of lilypond-book regtests for ': 'lilypond-book regressietesten voor ',
302 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
303 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
305 'Doc tarball for ': 'Tarball met documentation voor ',
310 'Music glossary': '音乐术语表',
320 'Contributor': '贡献者',
323 ' (split HTML)': ' (分开的 HTML)',
324 ' (big HTML)': ' (大的 HTML)',
326 'Regression tests for ': '回归测试 ',
327 'PDF of regtests for ': '回归测试的 PDF ',
328 'abc2ly Regression tests for ': 'abc2ly 回归测试 ',
329 'PDF of abc2ly regtests for ': 'abc2ly 的 PDF 回归测试 ',
330 'lilypond-book Regression tests for ': 'lilypond-book 回归测试 ',
331 'PDF of lilypond-book regtests for ': 'lilypond-book 的 PDF 回归测试 ',
332 'MusicXML Regression tests for ': 'MusicXML 回归测试 ',
333 'PDF of MusicXML regtests for ': 'MusicXML 的 PDF 回归测试 ',
335 'Doc tarball for ': '为文档压缩包',
351 myDir = os.path.dirname(sys.argv[0])
352 # use two abspaths to work around some windows python bug
353 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
354 topDir = os.path.abspath( topDir )
357 # TODO: this might be useful for other scripts; can we make it available?
358 manuals = map(lambda x: os.path.splitext(x)[0],
359 map(os.path.basename,
360 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
361 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
362 manuals.append('internals')
365 version_file_path = os.path.join(topDir, "VERSION")
367 version_contents = open(version_file_path).readlines()
371 for line in version_contents:
372 if (line.startswith('MAJOR_VERSION')):
374 if (line.startswith('MINOR_VERSION')):
376 if (line.startswith('PATCH_LEVEL')):
378 if (line.startswith('VERSION_STABLE')):
379 VERSION_STABLE = line[15:-1]
380 if (line.startswith('VERSION_DEVEL')):
381 VERSION_DEVEL = line[14:-1]
383 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
385 def _ (string, lang):
386 return translations.get (lang.split ('_')[0], {}).get (string, None)
389 # let's not barf, but print a warning when something's missing
390 def getTrans(text, lang):
393 trans = _ (text, lang)
396 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
399 def macroLang(name, lang):
401 return name + '-' + lang
404 def make_macro(name, string):
410 def make_download(name, osA, osB, version, revision, text):
411 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
412 string += osA + "lilypond-"
413 string += version + "-" + revision
414 string += "." + osB + ",\n"
416 string += ": LilyPond "
417 string += version + "-" + revision
419 make_macro(name, string)
421 def make_download_source(name, version, lang):
422 assert "." in version
423 vstring = "v%s.%s" % tuple(version.split(".", 2)[0:2])
424 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
425 string += vstring + "/"
426 string += "lilypond-" + version + ".tar.gz"
428 string += getTrans("Source", lang)
429 string += ": lilypond-" + version + ".tar.gz"
431 make_macro(macroLang(name,lang), string)
433 def make_all_downloads(macroName, version):
434 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
435 "linux-x86.sh", version, "1", "GNU/Linux x86")
436 make_download("download"+macroName+"LinuxBig", "linux-64/",
437 "linux-64.sh", version, "1", "GNU/Linux 64")
438 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
439 "linux-ppc.sh", version, "1", "GNU/Linux PPC")
441 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
442 "freebsd-x86.sh", version, "1", "FreeBSD i386")
443 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
444 "freebsd-64.sh", version, "1", "FreeBSD amd64")
446 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
447 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
448 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
449 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
451 make_download("download"+macroName+"Windows", "mingw/",
452 "mingw.exe", version, "1", "Windows")
454 def make_ver_link(macroname, url, linktext):
460 make_macro(macroname, string)
462 # TODO: this kind of thing should really be in a central place for
463 # lilypond python build scripts
464 def translateNameToUrl(manual, version):
465 ver_split = version.split('.')
466 ver_minor = ver_split[0] + '.' + ver_split[1]
467 url = depth + "doc/v" + ver_minor + "/Documentation/"
471 def addLang(url, lang):
473 base, ext = os.path.splitext(url)
474 return base + '.' + lang + ext
478 def make_manual_links(name, version, lang):
479 """Here is where all the macros manualStableLearningSplit,
480 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
481 created on the fly. Hopefully this documentation string will help
482 others a bit while grepping for those.
486 # TODO: this is a stupid way of doing it
487 if (m=='music-glossary'):
490 mshort = m.capitalize()
491 if (manual=='music-glossary'):
492 manual = 'Music glossary'
493 url = translateNameToUrl(m, version)
495 if (url.endswith('.html')):
496 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
498 getTrans(manual.capitalize(),lang) + '.pdf')
499 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
501 getTrans(manual.capitalize(),lang) +
502 getTrans(' (split HTML)',lang))
503 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
505 getTrans(manual.capitalize(),lang) +
506 getTrans(' (big HTML)',lang))
509 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
510 # TODO: this is an even stupider way of doing it
511 addLang(url+'.pdf', lang),
512 getTrans(manual.capitalize(),lang) + '.pdf')
513 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
514 addLang(url + '/index.html', lang),
515 getTrans(manual.capitalize(),lang) +
516 getTrans(' (split HTML)',lang))
517 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
518 addLang(url + '-big-page.html', lang),
519 getTrans(manual.capitalize(),lang) +
520 getTrans(' (big HTML)',lang))
521 newurl = url + '/index.html'
522 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
523 addLang(newurl, lang),
524 getTrans(manual.capitalize(),lang))
526 def make_regtest_links(name, version, lang):
527 ver_split = version.split('.')
528 ver_minor = ver_split[0] + '.' + ver_split[1]
529 url = depth + "doc/v" + ver_minor + "/input/regression/"
531 make_ver_link(macroLang("regtest"+name, lang),
532 url+"collated-files.html",
533 getTrans("Regression tests for ", lang)+version)
534 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
535 url+"collated-files.pdf",
536 getTrans("PDF of regtests for ", lang)+version)
537 make_ver_link(macroLang("regtest"+name+"Xml", lang),
538 url+"musicxml/collated-files.html",
539 getTrans("MusicXML Regression tests for ", lang)+version)
540 make_ver_link(macroLang("regtest"+name+"Abc", lang),
541 url+"abc2ly/collated-files.html",
542 getTrans("abc2ly Regression tests for ", lang)+version)
543 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
544 url+"lilypond-book/collated-files.html",
545 getTrans("lilypond-book Regression tests for ", lang)+version)
546 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
547 url+"musicxml/collated-files.pdf",
548 getTrans("PDF of MusicXML regtests for ", lang)+version)
549 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
550 url+"abc2ly/collated-files.pdf",
551 getTrans("PDF of abc2ly regtests for ", lang)+version)
552 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
553 url+"lilypond-book/collated-files.pdf",
554 getTrans("PDF of lilypond-book regtests for ", lang)+version)
556 def make_doctarball_links(name, version, lang):
557 url = depth + "download/binaries/documentation/lilypond-"
558 # ugly FIXME, but proper build number support isn't Critical.
559 url += version + "-1"
560 url += ".documentation.tar.bz2"
561 make_ver_link(macroLang("doctarball"+name, lang),
562 url, getTrans("Doc tarball for ", lang)+version)
564 print "@c This file was autogenerated"
565 print "@c from: %s" % VERSION
566 print "@c by: %s" % sys.argv[0]
568 print "@c ************************ Download binaries ************"
571 make_all_downloads("Stable", VERSION_STABLE)
572 make_all_downloads("Devel", VERSION_DEVEL)
574 print "@c ************************ Download source ************"
578 print "@c *********", lang or "en", "***"
579 make_download_source("downloadStableSource", VERSION_STABLE, lang)
580 make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
582 print "@c ************************ Manual links ************"
586 print "@c *********", lang or "en", "***"
587 make_manual_links("Stable", VERSION_STABLE, lang)
588 make_manual_links("Devel", VERSION_DEVEL, lang)
590 make_doctarball_links("Stable", VERSION_STABLE, lang)
591 make_doctarball_links("Devel", VERSION_DEVEL, lang)
593 print "@c ************************ Regtest links ************"
597 print "@c *********", lang or "en", "***"
598 make_regtest_links("Stable", VERSION_STABLE, lang)
599 make_regtest_links("Devel", VERSION_DEVEL, lang)
600 print "@c ***************************************************"