]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
Web build: add translation build for weblinks.
[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 langs = ['', 'es']
21
22 translations = {
23     'es': {
24         'Source': 'Código fuente',
25
26         'Learning': 'Aprendizaj',
27         'Music glossary': 'Glosario',
28         'Essay': 'a',
29         'Notation': 'b',
30         'Usage': 'c',
31         'Snippets': 'd',
32         'Web': 'e',
33         'Changes': 'f',
34         'Extending': 'g',
35         'Internals': 'h',
36         'Contributor': 'Guía del colaborador',
37
38 # keep the spaces!
39         ' (split HTML)': ' (muchas páginas HTML)',
40         ' (big HTML)': ' (como una sola página HTML enorme)',
41
42         'Regression tests for ': 'aa ',
43         'PDF of regtests for ': 'bb ',
44         'MusicXML Regression tests for ': 'cc ',
45         'PDF of MusicXML regtests for ': 'dd ',
46
47         'Doc tarball for ': 'ee ',
48         ' (did not exist in 2.12)': ' (existes la nottes e 2.12)',
49      },
50     'fr': {
51         'Learning': 'Apprener?',
52         'Music glossary': 'Lizes ici pour les motes?',
53      },
54 }
55
56
57
58 ### actual program
59
60
61 VERSION_STABLE = ""
62 VERSION_DEVEL = ""
63
64 try:
65     topDir = sys.argv[1]
66 except:
67     myDir = os.path.dirname(sys.argv[0])
68     # use two abspaths to work around some windows python bug
69     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
70     topDir = os.path.abspath( topDir )
71
72
73 # TODO: this might be useful for other scripts; can we make it available?
74 manuals = map(lambda x: os.path.splitext(x)[0],
75               map(os.path.basename,
76                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
77 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
78 manuals.append('internals')
79
80
81 version_file_path = os.path.join(topDir, "VERSION")
82
83 version_contents = open(version_file_path).readlines()
84 major = 0
85 minor = 0
86 patch = 0
87 for line in version_contents:
88     if (line.startswith('MAJOR_VERSION')):
89         major = line[14:-1]
90     if (line.startswith('MINOR_VERSION')):
91         minor = line[14:-1]
92     if (line.startswith('PATCH_LEVEL')):
93         patch = line[12:-1]
94     if (line.startswith('VERSION_STABLE')):
95         VERSION_STABLE = line[15:-1]
96     if (line.startswith('VERSION_DEVEL')):
97         VERSION_DEVEL = line[14:-1]
98
99 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
100
101 def getTrans(text, lang):
102     if (lang != ''):
103         text = translations[lang][text]
104     return text
105
106 def macroLang(name, lang):
107     if (lang != ''):
108         return name + '-' + lang
109     return name
110
111 def make_macro(name, string):
112     print "@macro", name
113     print string
114     print "@end macro"
115     print ""
116
117 def make_download(name, osA, osB, version, revision, text):
118     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
119     string += osA + "lilypond-"
120     string += version + "-" + revision
121     string += "." + osB + ",\n"
122     string += text
123     string += ": LilyPond "
124     string += version + "-" + revision
125     string += "}"
126     make_macro(name, string)
127
128 def make_download_source(name, vstring, version, lang):
129     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
130     string += vstring + "/"
131     string += "lilypond-" + version + ".tar.gz"
132     string += ", "
133     string += getTrans("Source", lang)
134     string += ": lilypond-" + version + ".tar.gz"
135     string += "}"
136     make_macro(macroLang(name,lang), string)
137
138 def make_all_downloads(macroName, version):
139     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
140         "linux-x86.sh",    version, "1", "Linux x86")
141     make_download("download"+macroName+"LinuxBig", "linux-64/",
142         "linux-64.sh", version, "1", "Linux 64")
143     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
144         "linux-ppc.sh", version, "1", "Linux PPC")
145
146     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
147         "freebsd-x86.sh", version, "1", "FreeBSD i386")
148     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
149         "freebsd-64.sh", version, "1", "FreeBSD amd64")
150
151     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
152         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
153     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
154         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
155
156     make_download("download"+macroName+"Windows", "mingw/",
157         "mingw.exe", version, "1", "Windows")
158
159 def make_ver_link(macroname, url, linktext):
160     string = "@uref{"
161     string += url
162     string += ","
163     string += linktext
164     string += "}"
165     make_macro(macroname, string)
166
167 # TODO: this kind of thing should really be in a central place for
168 # lilypond python build scripts
169 def translateNameToUrl(manual, version):
170     ver_split = version.split('.')
171     ver_minor = ver_split[0] + '.' + ver_split[1]
172     url = depth + "doc/v" + ver_minor + "/Documentation/"
173
174     if (ver_minor == '2.13'):
175         return url+manual
176     if (ver_minor == '2.12'):
177         if (manual=='learning'):
178             return url+'user/lilypond-learning'
179         elif (manual=='internals'):
180             return url+'user/lilypond-internals'
181         elif (manual=='notation'):
182             return url+'user/lilypond'
183         elif (manual=='usage'):
184             return url+'user/lilypond-program'
185         elif (manual=='snippets'):
186             return url+'../input/lsr/lilypond-snippets'
187         elif (manual=='changes'):
188             return url+'topdocs/NEWS.html'
189         elif (manual=='music-glossary'):
190             return url+'user/music-glossary'
191         elif (manual=='essay'):
192             return url+'user/lilypond-learning/Background.html'
193         elif (manual=='extending'):
194             return url+'user/lilypond/Interfaces-for-programmers.html'
195         else:
196             return ''
197
198
199 def make_manual_links(name, version, lang):
200     for m in manuals:
201         manual = m
202         # TODO: this is a stupid way of doing it
203         if (m=='music-glossary'):
204             mshort = 'Glossary'
205         else:
206             mshort = m.capitalize()
207         if (manual=='music-glossary'):
208             manual = 'Music glossary'
209         url = translateNameToUrl(m, version)
210
211         if (url == ''):
212             # can't have a comma here due to texinfo
213             make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
214                 "http://lilypond.org",
215                 mshort+getTrans(" (did not exist in 2.12)",lang))
216             make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
217                 "http://lilypond.org",
218                 mshort+getTrans(" (did not exist in 2.12)",lang))
219             make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
220                 "http://lilypond.org",
221                 mshort+getTrans(" (did not exist in 2.12)",lang))
222             make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
223                 "http://lilypond.org",
224                 mshort+getTrans(" (did not exist in 2.12)",lang))
225             continue
226         make_ver_link(macroLang("manual"+name+mshort+'Pdf',lang),
227                   url + '.pdf',
228                   getTrans(manual.capitalize(),lang) + '.pdf')
229         make_ver_link(macroLang("manual"+name+mshort+'Split',lang),
230                   url + '/index.html',
231                   getTrans(manual.capitalize(),lang) +
232                   getTrans(' (split HTML)',lang))
233         make_ver_link(macroLang("manual"+name+mshort+'Big',lang),
234                   url + '-big-page.html',
235                   getTrans(manual.capitalize(),lang) +
236                   getTrans(' (split HTML)',lang))
237         # this is stupid and I shouldn't have bothered trying
238         # to support the 2.12 docs and it will be deleted once
239         # 2.14 is out and the website won't be visible to users
240         # until 2.14 is out.  -gp
241         if (url.endswith('.html')):
242             newurl = url
243         else:
244             newurl = url + '/index.html'
245         make_ver_link(macroLang("manual"+name+mshort+'SplitNoName',lang),
246                   newurl,
247                   manual.capitalize())
248
249 def make_regtest_links(name, version, lang):
250     ver_split = version.split('.')
251     ver_minor = ver_split[0] + '.' + ver_split[1]
252     url = depth + "doc/v" + ver_minor + "/input/regression/"
253
254     make_ver_link(macroLang("regtest"+name, lang),
255         url+"collated-files.html",
256         getTrans("Regression tests for ", lang)+version)
257     make_ver_link(macroLang("regtest"+name+"Pdf", lang),
258         url+"collated-files.pdf",
259         getTrans("PDF of regtests for ", lang)+version)
260     make_ver_link(macroLang("regtest"+name+"Xml", lang),
261         url+"musicxml/collated-files.html",
262         getTrans("MusicXML Regression tests for ", lang)+version)
263     make_ver_link(macroLang("regtest"+name+"XmlPdf", lang),
264          url+"musicxml/collated-files.html",
265         getTrans("PDF of MusicXML regtests for ", lang)+version)
266
267 def make_doctarball_links(name, version, lang):
268     url = depth + "download/binaries/documentation/lilypond-"
269     # ugly FIXME, but proper build number support isn't Critical.
270     url += version + "-1"
271     url += ".documentation.tar.bz2"
272     make_ver_link(macroLang("doctarball"+name, lang),
273         url, getTrans("Doc tarball for ", lang)+version)
274
275 print "@c ************************ Download binaries ************"
276 make_all_downloads("Stable", VERSION_STABLE)
277 make_all_downloads("Devel", VERSION_DEVEL)
278
279 print "@c ************************ Download source ************"
280 # FIXME: icky hard-coding!  -gp
281 for lang in langs:
282     print "@c *********", lang, "***"
283     make_download_source("downloadStableSource","v2.12",VERSION_STABLE,lang)
284     make_download_source("downloadDevelSource","v2.13",VERSION_DEVEL,lang)
285
286 print "@c ************************ Manual links ************"
287 for lang in langs:
288     print "@c *********", lang, "***"
289     make_manual_links("Stable", VERSION_STABLE,lang)
290     make_manual_links("Devel", VERSION_DEVEL,lang)
291
292     make_doctarball_links("Stable", VERSION_STABLE,lang)
293     make_doctarball_links("Devel", VERSION_DEVEL,lang)
294
295 print "@c ************************ Regtest links ************"
296 for lang in langs:
297     print "@c *********", lang, "***"
298     make_regtest_links("Stable", VERSION_STABLE,lang)
299     make_regtest_links("Devel", VERSION_DEVEL,lang)
300
301