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 # these links are relative from /website/ on lilypond.org
15 ### translation data -- shouldn't be here; see issue
16 ### http://code.google.com/p/lilypond/issues/detail?id=1050
18 #langs = ['', 'cs', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl', 'zh']
19 langs = ['', 'cs', 'de', 'es', 'fr', 'hu', 'it', 'ja', 'nl', 'zh']
21 # Get/update node translations
23 for i in cs de es fr hu it ja nl zh; do
25 (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/* ) \
26 | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
27 | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
35 'Learning': 'Einführung',
36 'Music glossary': 'Glossar',
38 'Notation': 'Notation',
40 'Snippets': 'Schnipsel',
42 'Changes': 'Änderungen',
44 'Extending': 'Erweitern',
45 'Internals': 'Interna',
46 'Contributor': 'Beitragen',
48 ' (split HTML)': ' (geteiltes HTML)',
49 ' (big HTML)': ' (großes HTML)',
51 'Regression tests for ': 'Regressionstests für ',
52 'PDF of regtests for ': 'PDF der Regressionstests für ',
53 'MusicXML Regression tests for ': 'MusicXML Regressionstests für ',
54 'PDF of MusicXML regtests for ': 'PDF der MusicXML Regressionstests für ',
56 'Doc tarball for ': 'Dokumentation tar-gepackt für ',
57 ' (did not exist in 2.12)': ' (nicht existent in 2.12)',
60 'Source': 'Código fuente',
62 'Learning': 'Aprendizaje',
63 'Music glossary': 'Glosario',
65 'Notation': 'Notación',
66 'Usage': 'Utilización',
67 'Snippets': 'Fragmentos',
70 'Extending': 'Extensión',
71 'Internals': 'Funcionamiento interno',
72 'Contributor': 'Guía del colaborador',
75 ' (split HTML)': ' (HTML seccionado)',
76 ' (big HTML)': ' (HTML monolítico)',
78 'Regression tests for ': 'Pruebas de regresión para ',
79 'PDF of regtests for ': 'Pruebas en PDF para ',
80 'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
81 'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
83 'Doc tarball for ': 'Tarball de la documentación para ',
84 ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
89 'Learning': 'Initiation',
90 'Music glossary': 'Glossaire',
92 'Notation': 'Notation',
93 'Usage': 'Utilisation',
94 'Snippets': 'Morceaux choisis',
96 'Changes': 'Nouveautés',
97 'Extending': 'Extension',
98 'Internals': 'Propriétés internes',
99 'Contributor': 'Guide du contributeur',
102 ' (split HTML)': ' (HTML multipages)',
103 ' (big HTML)': ' (HTML en page unique)',
105 'Regression tests for ': 'Tests de régression pour ',
106 'PDF of regtests for ': 'PDF des tests de régression pour ',
107 'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
108 'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
110 'Doc tarball for ': 'Archive de la documentation pour ',
111 ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
115 'Learning': 'Tankönyv',
116 'Music glossary': 'Fogalomtár',
118 'Notation': 'Kottaírás',
119 'Usage': 'Használat',
120 'Snippets': 'Kódrészletek',
122 'Changes': 'Változások',
123 'Extending': 'Bővítés',
124 'Internals': 'Belső működés',
125 'Contributor': 'Közreműködés',
127 ' (split HTML)': ' (HTML oldalak)',
128 ' (big HTML)': ' (egy nagy HTML oldal)',
130 'Regression tests for ': 'Regressziós tesztek - verzió: ',
131 'PDF of regtests for ': 'PDF formátumban - verzió: ',
132 'MusicXML Regression tests for ': 'MusicXML regressziós tesztek - verzió: ',
133 'PDF of MusicXML regtests for ': 'PDF formátumban - verzió: ',
135 'Doc tarball for ': 'Tömörített csomag - verzió: ',
136 ' (did not exist in 2.12)': ' (nem létezett a 2.12-es verzióban)',
141 'Music glossary': '用語集',
145 'Snippets': 'コード断片集',
151 'Internals': '内部リファレンス',
152 'Contributor': '貢献者向けガイド',
155 ' (split HTML)': ' (ページ毎に分割された HTML)',
156 ' (big HTML)': ' (1 つの大きな HTML)',
158 'Regression tests for ': '回帰テスト バージョン ',
159 'PDF of regtests for ': '回帰テスト (PDF 版) バージョン ',
160 'MusicXML Regression tests for ': 'MusicXML 回帰テスト バージョン ',
161 'PDF of MusicXML regtests for ': 'MusicXML 回帰テスト (PDF 版) バージョン ',
163 'Doc tarball for ': 'ドキュメント アーカイブ バージョン ',
164 ' (did not exist in 2.12)': ' (バージョン 2.12 には存在しません)',
168 'Source': 'Broncode',
170 'Learning': 'Beginnen',
171 'Music glossary': 'Terminologie',
173 'Notation': 'Notatie',
175 'Snippets': 'Snippers',
177 'Changes': 'Veranderingen',
178 'Extending': 'Uitbreidingen',
179 'Internals': 'Internals',
180 'Contributor': 'Contributor',
183 ' (split HTML)': ' (opgesplitste HTML)',
184 ' (big HTML)': ' (grote pagina HTML)',
186 'Regression tests for ': 'Regressietesten voor ',
187 'PDF of regtests for ': 'PDF van regressietesten voor ',
188 'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
189 'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
191 'Doc tarball for ': 'Tarball met documentation voor ',
192 ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
197 'Music glossary': '音乐术语表',
207 'Contributor': '贡献者',
210 ' (split HTML)': ' (分开的HTML',
211 ' (big HTML)': ' (大的HTML)',
213 'Regression tests for ': '回归测试',
214 'PDF of regtests for ': '回归的PDF',
215 'MusicXML Regression tests for ': 'MusicXML回归测试',
216 'PDF of MusicXML regtests for ': 'MusicXML的PDF回归',
218 'Doc tarball for ': '为文档压缩包',
219 ' (did not exist in 2.12)': ' (在2.12中不存在)',
235 myDir = os.path.dirname(sys.argv[0])
236 # use two abspaths to work around some windows python bug
237 topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
238 topDir = os.path.abspath( topDir )
241 # TODO: this might be useful for other scripts; can we make it available?
242 manuals = map(lambda x: os.path.splitext(x)[0],
243 map(os.path.basename,
244 glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
245 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
246 manuals.append('internals')
249 version_file_path = os.path.join(topDir, "VERSION")
251 version_contents = open(version_file_path).readlines()
255 for line in version_contents:
256 if (line.startswith('MAJOR_VERSION')):
258 if (line.startswith('MINOR_VERSION')):
260 if (line.startswith('PATCH_LEVEL')):
262 if (line.startswith('VERSION_STABLE')):
263 VERSION_STABLE = line[15:-1]
264 if (line.startswith('VERSION_DEVEL')):
265 VERSION_DEVEL = line[14:-1]
267 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
269 def _ (string, lang):
270 return translations.get (lang.split ('_')[0], {}).get (string, string)
273 # let's not barf, but print a warning when something's missing
274 def getTrans(text, lang):
275 trans = _ (text, lang)
278 sys.stderr.write ('create-weblinks-itexi: warning: [%(lang)s]: translation missing for: %(text)s\n' % locals ())
281 def macroLang(name, lang):
283 return name + '-' + lang
286 def make_macro(name, string):
292 def make_download(name, osA, osB, version, revision, text):
293 string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
294 string += osA + "lilypond-"
295 string += version + "-" + revision
296 string += "." + osB + ",\n"
298 string += ": LilyPond "
299 string += version + "-" + revision
301 make_macro(name, string)
303 def make_download_source(name, vstring, version, lang):
304 string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
305 string += vstring + "/"
306 string += "lilypond-" + version + ".tar.gz"
308 string += getTrans("Source", lang)
309 string += ": lilypond-" + version + ".tar.gz"
311 make_macro(macroLang(name,lang), string)
313 def make_all_downloads(macroName, version):
314 make_download("download"+macroName+"LinuxNormal", "linux-x86/",
315 "linux-x86.sh", version, "1", "Linux x86")
316 make_download("download"+macroName+"LinuxBig", "linux-64/",
317 "linux-64.sh", version, "1", "Linux 64")
318 make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
319 "linux-ppc.sh", version, "1", "Linux PPC")
321 make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
322 "freebsd-x86.sh", version, "1", "FreeBSD i386")
323 make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
324 "freebsd-64.sh", version, "1", "FreeBSD amd64")
326 make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
327 "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
328 make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
329 "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
331 make_download("download"+macroName+"Windows", "mingw/",
332 "mingw.exe", version, "1", "Windows")
334 def make_ver_link(macroname, url, linktext):
340 make_macro(macroname, string)
342 # TODO: this kind of thing should really be in a central place for
343 # lilypond python build scripts
344 def translateNameToUrl(manual, version):
345 ver_split = version.split('.')
346 ver_minor = ver_split[0] + '.' + ver_split[1]
347 url = depth + "doc/v" + ver_minor + "/Documentation/"
349 if (ver_minor == '2.12'):
350 if (manual=='learning'):
351 return url+'user/lilypond-learning'
352 elif (manual=='internals'):
353 return url+'user/lilypond-internals'
354 elif (manual=='notation'):
355 return url+'user/lilypond'
356 elif (manual=='usage'):
357 return url+'user/lilypond-program'
358 elif (manual=='snippets'):
359 return url+'../input/lsr/lilypond-snippets'
360 elif (manual=='changes'):
361 return url+'topdocs/NEWS.html'
362 elif (manual=='music-glossary'):
363 return url+'user/music-glossary'
364 elif (manual=='essay'):
365 return url+'user/lilypond-learning/Background.html'
366 elif (manual=='extending'):
367 return url+'user/lilypond/Interfaces-for-programmers.html'
373 def addLang(url, lang):
375 base, ext = os.path.splitext(url)
376 return base + '.' + lang + ext
380 def make_manual_links(name, version, lang):
381 """Here is where all the macros manualStableLearningSplit,
382 manualStableLearningBig, manualStableLearningSplitNoName, etc. are
383 created on the fly. Hopefully this documentation string will help
384 others a bit while grepping for those.
388 # TODO: this is a stupid way of doing it
389 if (m=='music-glossary'):
392 mshort = m.capitalize()
393 if (manual=='music-glossary'):
394 manual = 'Music glossary'
395 url = translateNameToUrl(m, version)
398 # can't have a comma here due to texinfo
399 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
400 "http://lilypond.org",
401 mshort+getTrans(" (did not exist in 2.12)",lang))
402 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
403 "http://lilypond.org",
404 mshort+getTrans(" (did not exist in 2.12)",lang))
405 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
406 "http://lilypond.org",
407 mshort+getTrans(" (did not exist in 2.12)",lang))
408 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
409 "http://lilypond.org",
410 mshort+getTrans(" (did not exist in 2.12)",lang))
412 # this is stupid and I shouldn't have bothered trying
413 # to support the 2.12 docs and it will be deleted once
414 # 2.14 is out and the website won't be visible to users
415 # until 2.14 is out. -gp
416 if (url.endswith('.html')):
417 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
419 getTrans(manual.capitalize(),lang) + '.pdf')
420 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
422 getTrans(manual.capitalize(),lang) +
423 getTrans(' (split HTML)',lang))
424 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
426 getTrans(manual.capitalize(),lang) +
427 getTrans(' (big HTML)',lang))
430 make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
431 # TODO: this is an even stupider way of doing it
432 addLang(url+'.pdf', lang),
433 getTrans(manual.capitalize(),lang) + '.pdf')
434 make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
435 addLang(url + '/index.html', lang),
436 getTrans(manual.capitalize(),lang) +
437 getTrans(' (split HTML)',lang))
438 make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
439 addLang(url + '-big-page.html', lang),
440 getTrans(manual.capitalize(),lang) +
441 getTrans(' (big HTML)',lang))
442 newurl = url + '/index.html'
443 make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
444 addLang(newurl, lang),
445 getTrans(manual.capitalize(),lang))
447 def make_regtest_links(name, version, lang):
448 ver_split = version.split('.')
449 ver_minor = ver_split[0] + '.' + ver_split[1]
450 url = depth + "doc/v" + ver_minor + "/input/regression/"
452 make_ver_link(macroLang("regtest"+name, lang),
453 url+"collated-files.html",
454 getTrans("Regression tests for ", lang)+version)
455 make_ver_link(macroLang("regtest"+name+"Pdf", lang),
456 url+"collated-files.pdf",
457 getTrans("PDF of regtests for ", lang)+version)
458 make_ver_link(macroLang("regtest"+name+"Xml", lang),
459 url+"musicxml/collated-files.html",
460 getTrans("MusicXML Regression tests for ", lang)+version)
461 make_ver_link(macroLang("regtest"+name+"Abc", lang),
462 url+"abc2ly/collated-files.html",
463 getTrans("abc2ly Regression tests for ", lang)+version)
464 make_ver_link(macroLang("regtest"+name+"LilypondBook", lang),
465 url+"lilypond-book/collated-files.html",
466 getTrans("lilypond-book Regression tests for ", lang)+version)
467 make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
468 url+"musicxml/collated-files.pdf",
469 getTrans("PDF of MusicXML regtests for ", lang)+version)
470 make_ver_link(macroLang("regtest"+name+"AbcPdf", lang),
471 url+"abc2ly/collated-files.pdf",
472 getTrans("PDF of abc2ly regtests for ", lang)+version)
473 make_ver_link(macroLang("regtest"+name+"LilypondBookPdf", lang),
474 url+"lilypond-book/collated-files.pdf",
475 getTrans("PDF of lilypond-book regtests for ", lang)+version)
477 def make_doctarball_links(name, version, lang):
478 url = depth + "download/binaries/documentation/lilypond-"
479 # ugly FIXME, but proper build number support isn't Critical.
480 url += version + "-1"
481 url += ".documentation.tar.bz2"
482 make_ver_link(macroLang("doctarball"+name, lang),
483 url, getTrans("Doc tarball for ", lang)+version)
485 print "@c ************************ Download binaries ************"
486 make_all_downloads("Stable", VERSION_STABLE)
487 make_all_downloads("Devel", VERSION_DEVEL)
489 print "@c ************************ Download source ************"
490 # FIXME: icky hard-coding! -gp
492 print "@c *********", lang, "***"
493 make_download_source("downloadStableSource","v2.14",VERSION_STABLE,lang)
494 make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
496 print "@c ************************ Manual links ************"
498 print "@c *********", lang, "***"
499 make_manual_links("Stable", VERSION_STABLE,lang)
500 make_manual_links("Devel", VERSION_DEVEL,lang)
502 make_doctarball_links("Stable", VERSION_STABLE,lang)
503 make_doctarball_links("Devel", VERSION_DEVEL,lang)
505 print "@c ************************ Regtest links ************"
507 print "@c *********", lang, "***"
508 make_regtest_links("Stable", VERSION_STABLE,lang)
509 make_regtest_links("Devel", VERSION_DEVEL,lang)