]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
create-weblinks-itexi.py: Enable 'fr'
[lilypond.git] / scripts / build / create-weblinks-itexi.py
1 #!@PYTHON@
2 # -*- coding: utf-8 -*-
3 # create-version-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 # these links are relative from /website/ on lilypond.org
13 depth = "../"
14
15 ### translation data -- shouldn't be here; see issue
16 ### http://code.google.com/p/lilypond/issues/detail?id=1050
17
18 # don't add your language to this list unless you have all the
19 # items.
20 # Hmm, is this a feature -- why not keep original english as a fallback?
21 langs = ['', 'es', 'fr', 'nl']
22
23 # Get/update node translations
24 '''
25 for i in es fr nl de hu ja it; do
26     echo "'"$i"': {"
27     (echo '--' ; grep -nH -B1 translationof Documentation/$i/web/*) \
28         | pytt '^--\n.*@(?:unnum|sub)[^ ]* (.*)\n.*@translationof (.*)\n' "'\2': '\1',\n" \
29         | grep -E 'Source|Learning|Glossary|Essay|Notation|Usage|Snippets|Web|Changes|Extending|Internals|Contributor'
30     echo "},"
31 done
32 '''
33
34 translations = {
35     'es': {
36         'Source': 'Código fuente',
37
38         'Learning': 'Aprendizaje',
39         'Music glossary': 'Glosario',
40         'Essay': 'Ensayo',
41         'Notation': 'Notación',
42         'Usage': 'Utilización',
43         'Snippets': 'Fragmentos',
44         'Web': 'Web',
45         'Changes': 'Cambios',
46         'Extending': 'Extensión',
47         'Internals': 'Funcionamiento interno',
48         'Contributor': 'Guía del colaborador',
49
50 # keep the spaces!
51         ' (split HTML)': ' (HTML seccionado)',
52         ' (big HTML)': ' (HTML monolítico)',
53
54         'Regression tests for ': 'Pruebas de regresión para ',
55         'PDF of regtests for ': 'Pruebas en PDF para ',
56         'MusicXML Regression tests for ': 'Pruebas de regresión de MusicXML para ',
57         'PDF of MusicXML regtests for ': 'Pruebas de MusicXML en PDF para ',
58
59         'Doc tarball for ': 'Tarball de la documentación para ',
60         ' (did not exist in 2.12)': ' (no existía en la versión 2.12)',
61      },
62     'fr': {
63         'Source': 'Sources',
64
65         'Learning': 'Initiation',
66         'Music glossary': 'Glossaire',
67         'Essay': 'Essai',
68         'Notation': 'Notation',
69         'Usage': 'Utilisation',
70         'Snippets': 'Morceaux choisis',
71         'Web': 'Web',
72         'Changes': 'Nouveautés',
73         'Extending': 'Extension',
74         'Internals': 'Propriétés internes',
75         'Contributor': 'Guide du contributeur',
76
77 # keep the spaces!
78         ' (split HTML)': ' (HTML multipages)',
79         ' (big HTML)': ' (HTML en page unique)',
80
81         'Regression tests for ': 'Tests de régression pour ',
82         'PDF of regtests for ': 'PDF des tests de régression pour ',
83         'MusicXML Regression tests for ': 'Tests de régression de MusicXML pour ',
84         'PDF of MusicXML regtests for ': 'PDF des tests de régression de MusicXML pour ',
85
86         'Doc tarball for ': 'Archive de la documentation pour ',
87         ' (did not exist in 2.12)': ' (non disponible pour la version 2.12)',
88         },
89     'nl': {
90         'Source': 'Broncode',
91
92         'Learning': 'Beginnen',
93         'Music glossary': 'Terminologie',
94         'Essay': 'Essay',
95         'Notation': 'Notatie',
96         'Usage': 'Gebruik',
97         'Snippets': 'Snippers',
98         'Web': 'Web',
99         'Changes': 'Veranderingen',
100         'Extending': 'Uitbreidingen',
101         'Internals': 'Internals',
102         'Contributor': 'Contributor',
103
104 # keep the spaces!
105         ' (split HTML)': ' (opgesplitste HTML)',
106         ' (big HTML)': ' (grote pagina HTML)',
107
108         'Regression tests for ': 'Regressietesten voor ',
109         'PDF of regtests for ': 'PDF van regressietesten voor ',
110         'MusicXML Regression tests for ': 'MusicXML regressietesten voor ',
111         'PDF of MusicXML regtests for ': 'MusicXML regressietesten voor ',
112
113         'Doc tarball for ': 'Tarball met documentation voor ',
114         ' (did not exist in 2.12)': ' (bestond nog niet in 2.12)',
115      },
116     'de': {
117         'Source': 'Quellen',
118         'Learning': 'Einführung',
119         'Music glossary': 'Glossar',
120         'Essay': 'Aufsatz',
121         'Notation': 'Notation',
122         'Usage': 'Benutzung',
123         'Snippets': 'Schnipsel',
124         'Web': 'Web',
125         'Changes': 'Änderungen',
126         'Internals': 'Interna',
127
128         #TODO
129         },
130     'hu': {
131         'Source': 'Forrás',
132         'Learning': 'Tankönyv',
133         'Music glossary': 'Fogalomtár',
134         'Essay': 'Esszé',
135         'Notation': 'Kottaírás',
136         'Usage': 'Használat',
137         'Snippets': 'Kódrészletek',
138         'Web': 'Web',
139         'Changes': 'Változások',
140         'Internals': 'Belső működés',
141
142         #TODO
143         },
144     'ja': {
145         'Source': 'ソース',
146         'Learning': '学習',
147         'Music glossary': '用語集',
148         'Essay': 'エッセー',
149         'Notation': '記譜法',
150         'Usage': '使用方法',
151         'Snippets': 'コード断片集',
152         'Web': 'Web',
153         'Changes': '変更点',
154         'Internals': '内部リファレンス',
155
156         #TODO
157         },
158     }
159
160
161
162
163 ### actual program
164
165
166 VERSION_STABLE = ""
167 VERSION_DEVEL = ""
168
169 try:
170     topDir = sys.argv[1]
171 except:
172     myDir = os.path.dirname(sys.argv[0])
173     # use two abspaths to work around some windows python bug
174     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
175     topDir = os.path.abspath( topDir )
176
177
178 # TODO: this might be useful for other scripts; can we make it available?
179 manuals = map(lambda x: os.path.splitext(x)[0],
180               map(os.path.basename,
181                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
182 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
183 manuals.append('internals')
184
185
186 version_file_path = os.path.join(topDir, "VERSION")
187
188 version_contents = open(version_file_path).readlines()
189 major = 0
190 minor = 0
191 patch = 0
192 for line in version_contents:
193     if (line.startswith('MAJOR_VERSION')):
194         major = line[14:-1]
195     if (line.startswith('MINOR_VERSION')):
196         minor = line[14:-1]
197     if (line.startswith('PATCH_LEVEL')):
198         patch = line[12:-1]
199     if (line.startswith('VERSION_STABLE')):
200         VERSION_STABLE = line[15:-1]
201     if (line.startswith('VERSION_DEVEL')):
202         VERSION_DEVEL = line[14:-1]
203
204 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
205
206 def getTrans(text, lang):
207     if (lang != ''):
208         text = translations[lang][text]
209     return text
210
211 def macroLang(name, lang):
212     if (lang != ''):
213         return name + '-' + lang
214     return name
215
216 def make_macro(name, string):
217     print "@macro", name
218     print string
219     print "@end macro"
220     print ""
221
222 def make_download(name, osA, osB, version, revision, text):
223     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
224     string += osA + "lilypond-"
225     string += version + "-" + revision
226     string += "." + osB + ",\n"
227     string += text
228     string += ": LilyPond "
229     string += version + "-" + revision
230     string += "}"
231     make_macro(name, string)
232
233 def make_download_source(name, vstring, version, lang):
234     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
235     string += vstring + "/"
236     string += "lilypond-" + version + ".tar.gz"
237     string += ", "
238     string += getTrans("Source", lang)
239     string += ": lilypond-" + version + ".tar.gz"
240     string += "}"
241     make_macro(macroLang(name,lang), string)
242
243 def make_all_downloads(macroName, version):
244     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
245         "linux-x86.sh",    version, "1", "Linux x86")
246     make_download("download"+macroName+"LinuxBig", "linux-64/",
247         "linux-64.sh", version, "1", "Linux 64")
248     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
249         "linux-ppc.sh", version, "1", "Linux PPC")
250
251     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
252         "freebsd-x86.sh", version, "1", "FreeBSD i386")
253     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
254         "freebsd-64.sh", version, "1", "FreeBSD amd64")
255
256     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
257         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
258     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
259         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
260
261     make_download("download"+macroName+"Windows", "mingw/",
262         "mingw.exe", version, "1", "Windows")
263
264 def make_ver_link(macroname, url, linktext):
265     string = "@uref{"
266     string += url
267     string += ","
268     string += linktext
269     string += "}"
270     make_macro(macroname, string)
271
272 # TODO: this kind of thing should really be in a central place for
273 # lilypond python build scripts
274 def translateNameToUrl(manual, version):
275     ver_split = version.split('.')
276     ver_minor = ver_split[0] + '.' + ver_split[1]
277     url = depth + "doc/v" + ver_minor + "/Documentation/"
278
279     if (ver_minor == '2.13'):
280         return url+manual
281     if (ver_minor == '2.12'):
282         if (manual=='learning'):
283             return url+'user/lilypond-learning'
284         elif (manual=='internals'):
285             return url+'user/lilypond-internals'
286         elif (manual=='notation'):
287             return url+'user/lilypond'
288         elif (manual=='usage'):
289             return url+'user/lilypond-program'
290         elif (manual=='snippets'):
291             return url+'../input/lsr/lilypond-snippets'
292         elif (manual=='changes'):
293             return url+'topdocs/NEWS.html'
294         elif (manual=='music-glossary'):
295             return url+'user/music-glossary'
296         elif (manual=='essay'):
297             return url+'user/lilypond-learning/Background.html'
298         elif (manual=='extending'):
299             return url+'user/lilypond/Interfaces-for-programmers.html'
300         else:
301             return ''
302
303
304 def make_manual_links(name, version, lang):
305     """Here is where all the macros manualStableLearningSplit,
306     manualStableLearningBig, manualStableLearningSplitNoName, etc. are
307     created on the fly.  Hopefully this documentation string will help
308     others a bit while grepping for those.
309     """
310     for m in manuals:
311         manual = m
312         # TODO: this is a stupid way of doing it
313         if (m=='music-glossary'):
314             mshort = 'Glossary'
315         else:
316             mshort = m.capitalize()
317         if (manual=='music-glossary'):
318             manual = 'Music glossary'
319         url = translateNameToUrl(m, version)
320
321         if (url == ''):
322             # can't have a comma here due to texinfo
323             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
324                 "http://lilypond.org",
325                 mshort+getTrans(" (did not exist in 2.12)",lang))
326             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
327                 "http://lilypond.org",
328                 mshort+getTrans(" (did not exist in 2.12)",lang))
329             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
330                 "http://lilypond.org",
331                 mshort+getTrans(" (did not exist in 2.12)",lang))
332             make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
333                 "http://lilypond.org",
334                 mshort+getTrans(" (did not exist in 2.12)",lang))
335             continue
336         make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
337                   url + '.pdf',
338                   getTrans(manual.capitalize(),lang) + '.pdf')
339         make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
340                   url + '/index.html',
341                   getTrans(manual.capitalize(),lang) +
342                   getTrans(' (split HTML)',lang))
343         make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
344                   url + '-big-page.html',
345                   getTrans(manual.capitalize(),lang) +
346                   getTrans(' (big HTML)',lang))
347         # this is stupid and I shouldn't have bothered trying
348         # to support the 2.12 docs and it will be deleted once
349         # 2.14 is out and the website won't be visible to users
350         # until 2.14 is out.  -gp
351         if (url.endswith('.html')):
352             newurl = url
353         else:
354             newurl = url + '/index.html'
355         make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
356                   newurl,
357                   getTrans(manual.capitalize(),lang))
358
359 def make_regtest_links(name, version, lang):
360     ver_split = version.split('.')
361     ver_minor = ver_split[0] + '.' + ver_split[1]
362     url = depth + "doc/v" + ver_minor + "/input/regression/"
363
364     make_ver_link(macroLang("regtest"+name, lang),
365         url+"collated-files.html",
366         getTrans("Regression tests for ", lang)+version)
367     make_ver_link(macroLang("regtest"+name+"Pdf", lang),
368         url+"collated-files.pdf",
369         getTrans("PDF of regtests for ", lang)+version)
370     make_ver_link(macroLang("regtest"+name+"Xml", lang),
371         url+"musicxml/collated-files.html",
372         getTrans("MusicXML Regression tests for ", lang)+version)
373     make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
374          url+"musicxml/collated-files.html",
375         getTrans("PDF of MusicXML regtests for ", lang)+version)
376
377 def make_doctarball_links(name, version, lang):
378     url = depth + "download/binaries/documentation/lilypond-"
379     # ugly FIXME, but proper build number support isn't Critical.
380     url += version + "-1"
381     url += ".documentation.tar.bz2"
382     make_ver_link(macroLang("doctarball"+name, lang),
383         url, getTrans("Doc tarball for ", lang)+version)
384
385 print "@c ************************ Download binaries ************"
386 make_all_downloads("Stable", VERSION_STABLE)
387 make_all_downloads("Devel", VERSION_DEVEL)
388
389 print "@c ************************ Download source ************"
390 # FIXME: icky hard-coding!  -gp
391 for lang in langs:
392     print "@c *********", lang, "***"
393     make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
394     make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
395
396 print "@c ************************ Manual links ************"
397 for lang in langs:
398     print "@c *********", lang, "***"
399     make_manual_links("Stable", VERSION_STABLE,lang)
400     make_manual_links("Devel", VERSION_DEVEL,lang)
401
402     make_doctarball_links("Stable", VERSION_STABLE,lang)
403     make_doctarball_links("Devel", VERSION_DEVEL,lang)
404
405 print "@c ************************ Regtest links ************"
406 for lang in langs:
407     print "@c *********", lang, "***"
408     make_regtest_links("Stable", VERSION_STABLE,lang)
409     make_regtest_links("Devel", VERSION_DEVEL,lang)
410
411