]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
e7caa311610f8dc8f282b4099ce1459cf5e1f813
[lilypond.git] / scripts / build / create-weblinks-itexi.py
1 #!@PYTHON@
2 # -*- coding: utf-8 -*-
3 # create-weblinks-itexi.py
4
5 """ when being called on lilypond.org, pass it the location of the
6 top source dir on the command-line. """
7
8 import sys
9 import os
10 import glob
11
12 ### translation data -- shouldn't be here; see issue
13 ### http://code.google.com/p/lilypond/issues/detail?id=1050
14
15 import langdefs
16 # GUB only has python 2.4 !!!
17 # langs = [i.code if i.code != 'en' else '' for i in langdefs.WEB_LANGUAGES]
18 langs = []
19 for lang in langdefs.WEB_LANGUAGES:
20     if lang.code == 'en':
21         langs.append('')
22     else:
23         langs.append(lang.code)
24
25
26 # these links are relative from /website/ on lilypond.org
27 depth = "../"
28
29 # Get/update node translations
30 '''
31 for i in cs de es fr hu it ja nl zh; do
32     echo "'"$i"': {"
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'
36     echo "},"
37 done
38 '''
39
40 translations = {
41     'cs': {
42         'Source': 'Source',
43         'Learning': 'Učení',
44         'Music glossary': 'Slovníček',
45         'Essay': 'Článek',
46         'Notation': 'Notový zápis',
47         'Usage': 'Používání',
48         'Snippets': 'Úryvky',
49         'Web': 'Web',
50         'Changes': 'Změny',
51
52         'Extending': 'Rozšíření',
53         'Internals': 'Vnitřnosti',
54         'Contributor': 'Vývojářské',
55
56         ' (split HTML)': ' (rozdělené HTML)',
57         ' (big HTML)': ' (velké HTML)',
58
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í ',
67
68         'Doc tarball for ': 'Doc tarball for ',
69         },
70     'de': {
71         'Source': 'Quellen',
72         'Learning': 'Einführung',
73         'Music glossary': 'Glossar',
74         'Essay': 'Aufsatz',
75         'Notation': 'Notation',
76         'Usage': 'Benutzung',
77         'Snippets': 'Schnipsel',
78         'Web': 'Web',
79         'Changes': 'Änderungen',
80
81         'Extending': 'Erweitern',
82         'Internals': 'Interna',
83         'Contributor': 'Beitragen',
84
85         ' (split HTML)': ' (geteiltes HTML)',
86         ' (big HTML)': ' (großes HTML)',
87
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 ',
96
97         'Doc tarball for ': 'Dokumentation tar-gepackt für ',
98         },
99     'es': {
100         'Source': 'Código fuente',
101
102         'Learning': 'Aprendizaje',
103         'Music glossary': 'Glosario',
104         'Essay': 'Ensayo',
105         'Notation': 'Notación',
106         'Usage': 'Utilización',
107         'Snippets': 'Fragmentos',
108         'Web': 'Web',
109         'Changes': 'Cambios',
110         'Extending': 'Extensión',
111         'Internals': 'Funcionamiento interno',
112         'Contributor': 'Guía del colaborador',
113
114 # keep the spaces!
115         ' (split HTML)': ' (HTML seccionado)',
116         ' (big HTML)': ' (HTML monolítico)',
117
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 ',
126
127         'Doc tarball for ': 'Tarball de la documentación para ',
128      },
129     'fr': {
130         'Source': 'Sources',
131
132         'Learning': 'Initiation',
133         'Music glossary': 'Glossaire',
134         'Essay': 'Essai',
135         'Notation': 'Notation',
136         'Usage': 'Utilisation',
137         'Snippets': 'Morceaux choisis',
138         'Web': 'Web',
139         'Changes': 'Nouveautés',
140         'Extending': 'Extension',
141         'Internals': 'Propriétés internes',
142         'Contributor': 'Guide du contributeur',
143
144 # keep the spaces!
145         ' (split HTML)': ' (HTML multipages)',
146         ' (big HTML)': ' (HTML en page unique)',
147
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 ',
156
157         'Doc tarball for ': 'Archive de la documentation pour ',
158         },
159     'hu': {
160         'Source': 'Forrás',
161         'Learning': 'Tankönyv',
162         'Music glossary': 'Fogalomtár',
163         'Essay': 'Esszé',
164         'Notation': 'Kottaírás',
165         'Usage': 'Használat',
166         'Snippets': 'Kódrészletek',
167         'Web': 'Web',
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',
172
173         ' (split HTML)': ' (HTML oldalak)',
174         ' (big HTML)': ' (egy nagy HTML oldal)',
175
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ó: ',
184
185         'Doc tarball for ': 'Tömörített csomag - verzió: ',
186         },
187     'it': {
188         'Source': 'Sorgenti',
189         'Learning': 'Apprendimento',
190         'Music glossary': 'Glossario',
191         'Essay': 'Saggio',
192         'Notation': 'Notazione',
193         'Usage': 'Uso',
194         'Snippets': 'Frammenti',
195         'Web': 'Web',
196         'Changes': 'Cambiamenti',
197         'Extending': 'Estendere',
198         'Internals': 'Funzionamento interno',
199         'Contributor': 'Guida del collaboratore',
200
201 # keep the spaces!
202         ' (split HTML)': ' (HTML multipagina)',
203         ' (big HTML)': ' (HTML pagina unica)',
204
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 ',
213
214         'Doc tarball for ': 'Archivio della documentazione per ',
215         },
216     'ja': {
217         'Source': 'ソース',
218         'Learning': '学習',
219         'Music glossary': '用語集',
220         'Essay': 'エッセー',
221         'Notation': '記譜法',
222         'Usage': '使用方法',
223         'Snippets': 'コード断片集',
224         'Web': 'Web',
225         'Changes': '変更点',
226
227         #TODO
228         'Extending': '拡張',
229         'Internals': '内部リファレンス',
230         'Contributor': '貢献者向けガイド',
231
232 # keep the spaces!
233         ' (split HTML)': ' (ページ毎に分割された HTML)',
234         ' (big HTML)': ' (1 つの大きな HTML)',
235
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 版) バージョン ',
244
245         'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
246
247         },
248     'nl': {
249         'Source': 'Broncode',
250
251         'Learning': 'Beginnen',
252         'Music glossary': 'Terminologie',
253         'Essay': 'Essay',
254         'Notation': 'Notatie',
255         'Usage': 'Gebruik',
256         'Snippets': 'Snippers',
257         'Web': 'Web',
258         'Changes': 'Veranderingen',
259         'Extending': 'Uitbreidingen',
260         'Internals': 'Internals',
261         'Contributor': 'Contributor',
262
263 # keep the spaces!
264         ' (split HTML)': ' (opgesplitste HTML)',
265         ' (big HTML)': ' (grote pagina HTML)',
266
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 ',
275
276         'Doc tarball for ': 'Tarball met documentation voor ',
277      },
278     'zh': {
279         'Source': '源码',
280         'Learning': '学习',
281         'Music glossary': '音乐术语表',
282         'Essay': '文章',
283         'Notation': '记谱法',
284         'Usage': '使用',
285         'Snippets': '片断',
286         'Web': 'Web',
287         'Changes': '变化',
288
289         'Extending': '扩展',
290         'Internals': '内部机制',
291         'Contributor': '贡献者',
292
293 # keep the spaces!
294         ' (split HTML)': ' (分开的 HTML)',
295         ' (big HTML)': ' (大的 HTML)',
296
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 回归测试 ',
305
306         'Doc tarball for ': '为文档压缩包',
307         },
308     }
309
310
311
312
313 ### actual program
314
315
316 VERSION_STABLE = ""
317 VERSION_DEVEL = ""
318
319 try:
320     topDir = sys.argv[1]
321 except:
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 )
326
327
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')
334
335
336 version_file_path = os.path.join(topDir, "VERSION")
337
338 version_contents = open(version_file_path).readlines()
339 major = 0
340 minor = 0
341 patch = 0
342 for line in version_contents:
343     if (line.startswith('MAJOR_VERSION')):
344         major = line[14:-1]
345     if (line.startswith('MINOR_VERSION')):
346         minor = line[14:-1]
347     if (line.startswith('PATCH_LEVEL')):
348         patch = line[12:-1]
349     if (line.startswith('VERSION_STABLE')):
350         VERSION_STABLE = line[15:-1]
351     if (line.startswith('VERSION_DEVEL')):
352         VERSION_DEVEL = line[14:-1]
353
354 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
355
356 def _ (string, lang):
357     return translations.get (lang.split ('_')[0], {}).get (string, None)
358
359 getTrans = _
360 # let's not barf, but print a warning when something's missing
361 def getTrans(text, lang):
362     if not lang:
363         return text
364     trans = _ (text, lang)
365     if not trans:
366         trans = text
367         sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
368     return trans
369
370 def macroLang(name, lang):
371     if lang:
372         return name + '-' + lang
373     return name
374
375 def make_macro(name, string):
376     print "@macro", name
377     print string
378     print "@end macro"
379     print ""
380
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"
386     string += text
387     string += ": LilyPond "
388     string += version + "-" + revision
389     string += "}"
390     make_macro(name, string)
391
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"
398     string += ", "
399     string += getTrans("Source", lang)
400     string += ": lilypond-" + version + ".tar.gz"
401     string += "}"
402     make_macro(macroLang(name,lang), string)
403
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")
411
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")
416
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")
421
422     make_download("download"+macroName+"Windows", "mingw/",
423         "mingw.exe", version, "1", "Windows")
424
425 def make_ver_link(macroname, url, linktext):
426     string = "@uref{"
427     string += url
428     string += ","
429     string += linktext
430     string += "}"
431     make_macro(macroname, string)
432
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/"
439
440     return url+manual
441
442 def addLang(url, lang):
443     if lang:
444         base, ext = os.path.splitext(url)
445         return base + '.' + lang + ext
446     else:
447         return url
448
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.
454     """
455     for m in manuals:
456         manual = m
457         # TODO: this is a stupid way of doing it
458         if (m=='music-glossary'):
459             mshort = 'Glossary'
460         else:
461             mshort = m.capitalize()
462         if (manual=='music-glossary'):
463             manual = 'Music glossary'
464         url = translateNameToUrl(m, version)
465
466         if (url.endswith('.html')):
467             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
468                       addLang(url, lang),
469                       getTrans(manual.capitalize(),lang) + '.pdf')
470             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
471                       addLang(url, lang),
472                       getTrans(manual.capitalize(),lang) +
473                       getTrans(' (split HTML)',lang))
474             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
475                       addLang(url, lang),
476                       getTrans(manual.capitalize(),lang) +
477                       getTrans(' (big HTML)',lang))
478             newurl = url
479         else:
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))
496
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/"
501
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)
526
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)
534
535 print "@c This file was autogenerated"
536 print "@c     from: %s" % VERSION
537 print "@c     by:   %s" % sys.argv[0]
538 print ""
539 print "@c ************************ Download binaries ************"
540 print ""
541
542 make_all_downloads("Stable", VERSION_STABLE)
543 make_all_downloads("Devel", VERSION_DEVEL)
544
545 print "@c ************************ Download source ************"
546 print ""
547
548 for lang in langs:
549     print "@c *********", lang or "en", "***"
550     make_download_source("downloadStableSource", VERSION_STABLE, lang)
551     make_download_source("downloadDevelSource", VERSION_DEVEL, lang)
552
553 print "@c ************************ Manual links ************"
554 print ""
555
556 for lang in langs:
557     print "@c *********", lang or "en", "***"
558     make_manual_links("Stable", VERSION_STABLE, lang)
559     make_manual_links("Devel", VERSION_DEVEL, lang)
560
561     make_doctarball_links("Stable", VERSION_STABLE, lang)
562     make_doctarball_links("Devel", VERSION_DEVEL, lang)
563
564 print "@c ************************ Regtest links ************"
565 print ""
566
567 for lang in langs:
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 ***************************************************"