Merge lp:~dholbach/help-app/1423871 into lp:~ubuntu-touch-coreapps-drivers/help-app/trunk
- 1423871
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 50 |
Proposed branch: | lp:~dholbach/help-app/1423871 |
Merge into: | lp:~ubuntu-touch-coreapps-drivers/help-app/trunk |
Diff against target: |
610 lines (+119/-114) 14 files modified
.bzrignore (+1/-1) HACKING (+1/-1) Makefile (+6/-2) edit-here/content/pages/apps.md (+0/-2) edit-here/content/pages/faq.md (+1/-3) edit-here/content/pages/get-in-touch.md (+0/-2) edit-here/content/pages/index.md (+2/-4) edit-here/generate-pot (+2/-0) edit-here/pelicanconf.py (+7/-0) edit-here/po/de.po (+25/-17) edit-here/po/help.pot (+20/-46) edit-here/theme/templates/base.html (+2/-1) edit-here/theme/templates/page.html (+1/-0) edit-here/translations.py (+51/-35) |
To merge this branch: | bzr merge lp:~dholbach/help-app/1423871 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
David Planella | Needs Fixing | ||
Nicholas Skaggs (community) | Needs Information | ||
Review via email:
|
Commit message
Description of the change
- 59. By Daniel Holbach
-
fix clean target

Daniel Holbach (dholbach) wrote : | # |
The clean target in the makefile would ignore failures of the rm call. (Note the '-' at the start of the line.) Still I just pushed a cleaner version of the code.
I'll look into the linking next.
- 60. By Daniel Holbach
-
update .pot file
- 61. By Daniel Holbach
-
Remove erroneous 'Title' from generated markdown
- 62. By Daniel Holbach
-
make cleanup more robust and smaller
- 63. By Daniel Holbach
-
update .pot file
- 64. By Daniel Holbach
-
catch NotADirectoryError error more appropriately

Daniel Holbach (dholbach) wrote : | # |
Hum, so I have problems figuring out how to make the linking work properly. According to http://
- 65. By Daniel Holbach
-
update German translation
- 66. By Daniel Holbach
-
fix typo
- 67. By Daniel Holbach
-
mention ubuntu-
html5-ui- toolkit as a prerequisite

Daniel Holbach (dholbach) wrote : | # |
Can we please get this merged? I'll file a separate bug for the broken links.

Daniel Holbach (dholbach) wrote : | # |
I filed bug 1424953 for this.
- 68. By Daniel Holbach
-
fix python code style issues
- 69. By Daniel Holbach
-
define common po4a args centrally, add comment
- 70. By Daniel Holbach
-
run po4a-updatepo as well
- 71. By Daniel Holbach
-
update German translation
- 72. By Daniel Holbach
-
update paths

David Planella (dpm) wrote : | # |
Looks good to me, thanks!
Just two comments:
- I initially suggested using a directory for each language to contain the generated files. In a conversation on IRC, Daniel mentioned that this presents an issue with CSS/JS relative imports' for the toolkit theme.
- On second thoughts, and if we cannot use the above, I'd suggest keeping the same filename for all files, but adding the language as a suffix, just as the Apache docs suggest to load translations [1]. That is:
- index.en-us.html
- index.de.html
- get-in-
- get-in-
[1] http://
(*) Note the - vs. _ and lowercase. This is for converting gettext language codes to BCP-47 language codes, which are understood by the browser: http://

David Planella (dpm) wrote : | # |
If this requires a big change to the branch, we could do the above on a separate one.

Daniel Holbach (dholbach) wrote : | # |
<dholbach> dpm, ok, I'll work on bug 1425010 next now, but maybe it'd make sense to land the branches now, so it'll be easier for others to look at the branches
<dholbach> the code is in better shape now then it was
and I'll try to make the following MPs more targetted
<dpm> dholbach, makes sense, thanks!
<dholbach> ok
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2015-02-10 14:46:34 +0000 |
3 | +++ .bzrignore 2015-02-24 09:19:38 +0000 |
4 | @@ -1,5 +1,5 @@ |
5 | app/www |
6 | *.click |
7 | edit-here/cache |
8 | -edit-here/content/pages/?? |
9 | +edit-here/content/pages/lang-??-* |
10 | edit-here/backup |
11 | |
12 | === modified file 'HACKING' |
13 | --- HACKING 2015-02-13 16:08:50 +0000 |
14 | +++ HACKING 2015-02-24 09:19:38 +0000 |
15 | @@ -7,7 +7,7 @@ |
16 | |
17 | Before you get started, run: |
18 | |
19 | - sudo apt install python-pelican po4a make bzr |
20 | + sudo apt install python-pelican po4a make bzr ubuntu-html5-ui-toolkit |
21 | |
22 | |
23 | Editing |
24 | |
25 | === modified file 'Makefile' |
26 | --- Makefile 2015-02-13 16:08:50 +0000 |
27 | +++ Makefile 2015-02-24 09:19:38 +0000 |
28 | @@ -1,12 +1,16 @@ |
29 | #!/usr/bin/make -f |
30 | |
31 | +ignored := $(shell bzr ignored | cut -d' ' -f1) |
32 | + |
33 | clean: |
34 | - bzr ignored | cut -d' ' -f1 | xargs rm -r |
35 | +ifneq ($(strip $(ignored)),) |
36 | + $(foreach fn, $(ignored), $(shell rm -r $(fn);)) |
37 | +endif |
38 | |
39 | click: html |
40 | cd app && click build . && mv *.click .. |
41 | |
42 | -html: |
43 | +html: clean |
44 | cd edit-here && ./generate-translations |
45 | make -C edit-here html |
46 | |
47 | |
48 | === modified file 'edit-here/content/pages/apps.md' |
49 | --- edit-here/content/pages/apps.md 2015-02-20 09:39:31 +0000 |
50 | +++ edit-here/content/pages/apps.md 2015-02-24 09:19:38 +0000 |
51 | @@ -1,6 +1,4 @@ |
52 | Title: FAQ - Apps |
53 | -URL: |
54 | -Save_as: pages/app.html |
55 | Lang: en |
56 | |
57 | Are you looking for a good way to do X and can't find it in the app |
58 | |
59 | === modified file 'edit-here/content/pages/faq.md' |
60 | --- edit-here/content/pages/faq.md 2015-02-20 09:39:31 +0000 |
61 | +++ edit-here/content/pages/faq.md 2015-02-24 09:19:38 +0000 |
62 | @@ -1,10 +1,8 @@ |
63 | Title: Get your questions answered. |
64 | -URL: |
65 | -Save_as: pages/faq.html |
66 | Lang: en |
67 | |
68 | We divided the questions up into categories, so you can spot yours more |
69 | easily. Here we go: |
70 | |
71 | - * [Apps](apps.html) |
72 | + * [Apps]({filename}apps.md) |
73 | * ... |
74 | |
75 | === modified file 'edit-here/content/pages/get-in-touch.md' |
76 | --- edit-here/content/pages/get-in-touch.md 2015-02-20 09:39:31 +0000 |
77 | +++ edit-here/content/pages/get-in-touch.md 2015-02-24 09:19:38 +0000 |
78 | @@ -1,6 +1,4 @@ |
79 | Title: Get in touch |
80 | -URL: |
81 | -Save_as: pages/get-in-touch.html |
82 | Lang: en |
83 | |
84 | Ubuntu has a huge community. You can easily get in touch with experts and |
85 | |
86 | === modified file 'edit-here/content/pages/index.md' |
87 | --- edit-here/content/pages/index.md 2015-02-20 09:39:31 +0000 |
88 | +++ edit-here/content/pages/index.md 2015-02-24 09:19:38 +0000 |
89 | @@ -1,6 +1,4 @@ |
90 | Title: Welcome to Help for Ubuntu for devices! |
91 | -URL: |
92 | -Save_as: pages/index.html |
93 | Lang: en |
94 | |
95 | The world-wide Ubuntu community wants to give you the best possible |
96 | @@ -12,7 +10,7 @@ |
97 | |
98 | in this app for you. |
99 | |
100 | -[Take me to the FAQ!](faq.html) |
101 | -[Get in touch](get-in-touch.html) |
102 | +[Take me to the FAQ!]({filename}faq.md) |
103 | +[Get in touch]({filename}get-in-touch.md) |
104 | |
105 | --- |
106 | |
107 | === modified file 'edit-here/generate-pot' |
108 | --- edit-here/generate-pot 2015-02-20 09:10:30 +0000 |
109 | +++ edit-here/generate-pot 2015-02-24 09:19:38 +0000 |
110 | @@ -13,6 +13,8 @@ |
111 | if not translations.clean_documents(): |
112 | sys.exit(1) |
113 | translations.generate_pot_file() |
114 | + if not translations.update_po_files(): |
115 | + sys.exit(1) |
116 | |
117 | if __name__ == '__main__': |
118 | try: |
119 | |
120 | === modified file 'edit-here/pelicanconf.py' |
121 | --- edit-here/pelicanconf.py 2015-02-09 13:40:52 +0000 |
122 | +++ edit-here/pelicanconf.py 2015-02-24 09:19:38 +0000 |
123 | @@ -12,6 +12,13 @@ |
124 | |
125 | DEFAULT_LANG = u'en' |
126 | |
127 | +DIRECT_TEMPLATES = [] |
128 | +SLUGIFY_SOURCE = 'basename' |
129 | +PAGE_URL = '{slug}.html' |
130 | +PAGE_SAVE_AS = '{slug}.html' |
131 | +PAGE_LANG_URL = '{slug}.html' |
132 | +PAGE_LANG_SAVE_AS = '{slug}.html' |
133 | + |
134 | # Feed generation is usually not desired when developing |
135 | FEED_ALL_ATOM = None |
136 | CATEGORY_FEED_ATOM = None |
137 | |
138 | === modified file 'edit-here/po/de.po' |
139 | --- edit-here/po/de.po 2015-02-13 16:08:50 +0000 |
140 | +++ edit-here/po/de.po 2015-02-24 09:19:38 +0000 |
141 | @@ -7,19 +7,19 @@ |
142 | msgid "" |
143 | msgstr "" |
144 | "Project-Id-Version: PACKAGE VERSION\n" |
145 | -"POT-Creation-Date: 2015-02-13 14:35+0100\n" |
146 | +"POT-Creation-Date: 2015-02-24 10:15+0100\n" |
147 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
148 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
149 | "Language-Team: LANGUAGE <LL@li.org>\n" |
150 | "Language: \n" |
151 | "MIME-Version: 1.0\n" |
152 | -"Content-Type: text/plain; charset=CHARSET\n" |
153 | +"Content-Type: text/plain; charset=UTF-8\n" |
154 | "Content-Transfer-Encoding: 8bit\n" |
155 | |
156 | #. type: Plain text |
157 | #: content/pages/faq.md:2 |
158 | msgid "Title: Get your questions answered." |
159 | -msgstr "" |
160 | +msgstr "Title: Antworten auf Deine Fragen." |
161 | |
162 | #. type: Plain text |
163 | #: content/pages/faq.md:5 |
164 | @@ -27,11 +27,13 @@ |
165 | "We divided the questions up into categories, so you can spot yours more " |
166 | "easily. Here we go:" |
167 | msgstr "" |
168 | +"Wir haben die Fragen in Kategorien aufgeteilt, so dass Du Deine schneller " |
169 | +"finden kannst. Los geht's:" |
170 | |
171 | #. type: Bullet: ' * ' |
172 | #: content/pages/faq.md:7 |
173 | -msgid "[Apps](apps.html)" |
174 | -msgstr "" |
175 | +msgid "[Apps]({filename}apps.md)" |
176 | +msgstr "[Apps]({filename}apps.md)" |
177 | |
178 | #. type: Bullet: ' * ' |
179 | #: content/pages/faq.md:7 |
180 | @@ -41,7 +43,7 @@ |
181 | #. type: Plain text |
182 | #: content/pages/index.md:2 |
183 | msgid "Title: Welcome to Help for Ubuntu for devices!" |
184 | -msgstr "" |
185 | +msgstr "Title: Willkommen bei der Hilfe für Ubuntu-Geräte!" |
186 | |
187 | #. type: Plain text |
188 | #: content/pages/index.md:5 |
189 | @@ -49,42 +51,48 @@ |
190 | "The world-wide Ubuntu community wants to give you the best possible " |
191 | "experience on your Ubuntu device. This is why we collected:" |
192 | msgstr "" |
193 | +"Die weltweite Ubuntu Community will Dir helfen, die bestmögliche " |
194 | +"Nutzererfahrung zu haben. Deswegen haben wir folgendes: " |
195 | |
196 | #. type: Bullet: ' * ' |
197 | #: content/pages/index.md:9 |
198 | msgid "answers to frequently asked questions" |
199 | -msgstr "" |
200 | +msgstr "Antworten auf oft-gestellte Fragen" |
201 | |
202 | #. type: Bullet: ' * ' |
203 | #: content/pages/index.md:9 |
204 | msgid "tips and tricks to make you more productive" |
205 | -msgstr "" |
206 | +msgstr "Tips und Tricks, die Dir das Leben leichter machen" |
207 | |
208 | #. type: Bullet: ' * ' |
209 | #: content/pages/index.md:9 |
210 | msgid "links to get in touch with experts and other community members" |
211 | msgstr "" |
212 | +"Links, um mit anderen Community-Mitgliedern und Experten in Kontakt zu kommen" |
213 | |
214 | #. type: Plain text |
215 | #: content/pages/index.md:11 |
216 | msgid "in this app for you." |
217 | -msgstr "" |
218 | +msgstr "in dieser App gesammelt" |
219 | |
220 | #. type: Plain text |
221 | #: content/pages/index.md:12 |
222 | -#, no-wrap |
223 | -msgid "[Take me to the FAQ!](faq.html) \n" |
224 | -msgstr "" |
225 | +#, fuzzy, no-wrap |
226 | +#| msgid "[Take me to the FAQ!](faq.html) \n" |
227 | +msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
228 | +msgstr "[Zu den Antworten!]({filename}faq.md) \n" |
229 | |
230 | #. type: Plain text |
231 | #: content/pages/index.md:14 |
232 | -msgid "[Get in touch](get-in-touch.html)" |
233 | -msgstr "" |
234 | +#, fuzzy |
235 | +#| msgid "[Get in touch](get-in-touch.html)" |
236 | +msgid "[Get in touch]({filename}get-in-touch.md)" |
237 | +msgstr "[Kontakt]({filename}get-in-touch.md)" |
238 | |
239 | #. type: Plain text |
240 | #: content/pages/apps.md:2 |
241 | msgid "Title: FAQ - Apps" |
242 | -msgstr "" |
243 | +msgstr "Title: FAQ - Apps" |
244 | |
245 | #. type: Plain text |
246 | #: content/pages/apps.md:5 |
247 | @@ -112,7 +120,7 @@ |
248 | #: content/pages/apps.md:11 |
249 | #, no-wrap |
250 | msgid "**Q:** Do you have Google Authenticator? \n" |
251 | -msgstr "" |
252 | +msgstr "**Q:** Habt ihr Google Authenticator? \n" |
253 | |
254 | #. type: Plain text |
255 | #: content/pages/apps.md:13 |
256 | @@ -125,7 +133,7 @@ |
257 | #. type: Plain text |
258 | #: content/pages/get-in-touch.md:2 |
259 | msgid "Title: Get in touch" |
260 | -msgstr "" |
261 | +msgstr "Title: Kontakt" |
262 | |
263 | #. type: Plain text |
264 | #: content/pages/get-in-touch.md:7 |
265 | |
266 | === modified file 'edit-here/po/help.pot' |
267 | --- edit-here/po/help.pot 2015-02-20 09:14:19 +0000 |
268 | +++ edit-here/po/help.pot 2015-02-24 09:19:38 +0000 |
269 | @@ -7,7 +7,7 @@ |
270 | msgid "" |
271 | msgstr "" |
272 | "Project-Id-Version: PACKAGE VERSION\n" |
273 | -"POT-Creation-Date: 2015-02-20 10:13+0100\n" |
274 | +"POT-Creation-Date: 2015-02-23 12:42+0100\n" |
275 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
276 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
277 | "Language-Team: LANGUAGE <LL@li.org>\n" |
278 | @@ -22,19 +22,19 @@ |
279 | msgstr "" |
280 | |
281 | #. type: Plain text |
282 | -#: content/pages/faq.md:5 content/de/pages/faq.md:5 |
283 | +#: content/pages/faq.md:5 |
284 | msgid "" |
285 | "We divided the questions up into categories, so you can spot yours more " |
286 | "easily. Here we go:" |
287 | msgstr "" |
288 | |
289 | #. type: Bullet: ' * ' |
290 | -#: content/pages/faq.md:7 content/de/pages/faq.md:7 |
291 | -msgid "[Apps](apps.html)" |
292 | +#: content/pages/faq.md:7 |
293 | +msgid "[Apps]({filename}apps.md)" |
294 | msgstr "" |
295 | |
296 | #. type: Bullet: ' * ' |
297 | -#: content/pages/faq.md:7 content/de/pages/faq.md:7 |
298 | +#: content/pages/faq.md:7 |
299 | msgid "..." |
300 | msgstr "" |
301 | |
302 | @@ -44,41 +44,41 @@ |
303 | msgstr "" |
304 | |
305 | #. type: Plain text |
306 | -#: content/pages/index.md:5 content/de/pages/index.md:5 |
307 | +#: content/pages/index.md:5 |
308 | msgid "" |
309 | "The world-wide Ubuntu community wants to give you the best possible " |
310 | "experience on your Ubuntu device. This is why we collected:" |
311 | msgstr "" |
312 | |
313 | #. type: Bullet: ' * ' |
314 | -#: content/pages/index.md:9 content/de/pages/index.md:9 |
315 | +#: content/pages/index.md:9 |
316 | msgid "answers to frequently asked questions" |
317 | msgstr "" |
318 | |
319 | #. type: Bullet: ' * ' |
320 | -#: content/pages/index.md:9 content/de/pages/index.md:9 |
321 | +#: content/pages/index.md:9 |
322 | msgid "tips and tricks to make you more productive" |
323 | msgstr "" |
324 | |
325 | #. type: Bullet: ' * ' |
326 | -#: content/pages/index.md:9 content/de/pages/index.md:9 |
327 | +#: content/pages/index.md:9 |
328 | msgid "links to get in touch with experts and other community members" |
329 | msgstr "" |
330 | |
331 | #. type: Plain text |
332 | -#: content/pages/index.md:11 content/de/pages/index.md:11 |
333 | +#: content/pages/index.md:11 |
334 | msgid "in this app for you." |
335 | msgstr "" |
336 | |
337 | #. type: Plain text |
338 | -#: content/pages/index.md:12 content/de/pages/index.md:12 |
339 | +#: content/pages/index.md:12 |
340 | #, no-wrap |
341 | -msgid "[Take me to the FAQ!](faq.html) \n" |
342 | +msgid "[Take me to the FAQ!]({filename}faq.md) \n" |
343 | msgstr "" |
344 | |
345 | #. type: Plain text |
346 | -#: content/pages/index.md:14 content/de/pages/index.md:14 |
347 | -msgid "[Get in touch](get-in-touch.html)" |
348 | +#: content/pages/index.md:14 |
349 | +msgid "[Get in touch]({filename}get-in-touch.md)" |
350 | msgstr "" |
351 | |
352 | #. type: Plain text |
353 | @@ -87,7 +87,7 @@ |
354 | msgstr "" |
355 | |
356 | #. type: Plain text |
357 | -#: content/pages/apps.md:5 content/de/pages/apps.md:5 |
358 | +#: content/pages/apps.md:5 |
359 | msgid "" |
360 | "Are you looking for a good way to do X and can't find it in the app store? " |
361 | "Want some suggestions to solve a particular problem?" |
362 | @@ -100,7 +100,7 @@ |
363 | msgstr "" |
364 | |
365 | #. type: Plain text |
366 | -#: content/pages/apps.md:10 content/de/pages/apps.md:10 |
367 | +#: content/pages/apps.md:10 |
368 | #, no-wrap |
369 | msgid "" |
370 | "**A:** If you have a Spotify premium account, just install 'CuteSpotify'\n" |
371 | @@ -109,13 +109,13 @@ |
372 | msgstr "" |
373 | |
374 | #. type: Plain text |
375 | -#: content/pages/apps.md:11 content/de/pages/apps.md:11 |
376 | +#: content/pages/apps.md:11 |
377 | #, no-wrap |
378 | msgid "**Q:** Do you have Google Authenticator? \n" |
379 | msgstr "" |
380 | |
381 | #. type: Plain text |
382 | -#: content/pages/apps.md:13 content/de/pages/apps.md:13 |
383 | +#: content/pages/apps.md:13 |
384 | #, no-wrap |
385 | msgid "" |
386 | "**A:** Sure, install the 'Authenticator' app from the software store.\n" |
387 | @@ -128,7 +128,7 @@ |
388 | msgstr "" |
389 | |
390 | #. type: Plain text |
391 | -#: content/pages/get-in-touch.md:7 content/de/pages/get-in-touch.md:7 |
392 | +#: content/pages/get-in-touch.md:7 |
393 | #, no-wrap |
394 | msgid "" |
395 | "Ubuntu has a huge community. You can easily get in touch with experts and\n" |
396 | @@ -139,36 +139,10 @@ |
397 | msgstr "" |
398 | |
399 | #. type: Plain text |
400 | -#: content/pages/get-in-touch.md:12 content/de/pages/get-in-touch.md:12 |
401 | +#: content/pages/get-in-touch.md:12 |
402 | msgid "" |
403 | "Another great place to **get involved** with Ubuntu is our very own [Ubuntu " |
404 | "Community Website](http://community.ubuntu.com/). You can very easily find " |
405 | "out about all the indiviual teams in Ubuntu, what they do, where they hang " |
406 | "out and how to get involved." |
407 | msgstr "" |
408 | - |
409 | -#. type: Plain text |
410 | -#: content/de/pages/faq.md:2 |
411 | -msgid "Title: Get your questions answered. Lang: en" |
412 | -msgstr "" |
413 | - |
414 | -#. type: Plain text |
415 | -#: content/de/pages/index.md:2 |
416 | -msgid "Title: Welcome to Help for Ubuntu for devices! Lang: en" |
417 | -msgstr "" |
418 | - |
419 | -#. type: Plain text |
420 | -#: content/de/pages/apps.md:2 |
421 | -msgid "Title: FAQ - Apps Lang: en" |
422 | -msgstr "" |
423 | - |
424 | -#. type: Plain text |
425 | -#: content/de/pages/apps.md:7 |
426 | -#, no-wrap |
427 | -msgid "**Q:** Habt ihr Spotify? \n" |
428 | -msgstr "" |
429 | - |
430 | -#. type: Plain text |
431 | -#: content/de/pages/get-in-touch.md:2 |
432 | -msgid "Title: Get in touch Lang: en" |
433 | -msgstr "" |
434 | |
435 | === modified file 'edit-here/theme/templates/base.html' |
436 | --- edit-here/theme/templates/base.html 2015-02-09 13:50:46 +0000 |
437 | +++ edit-here/theme/templates/base.html 2015-02-24 09:19:38 +0000 |
438 | @@ -1,5 +1,6 @@ |
439 | <!doctype html> |
440 | -<html lang="en"> |
441 | + |
442 | +<html lang="{% block html_lang %}{{ DEFAULT_LANG }}{% endblock %}"> |
443 | <head> |
444 | <title>Ubuntu for devices - Help</title> |
445 | <meta name="description" content="Ubuntu for devices - Help"> |
446 | |
447 | === modified file 'edit-here/theme/templates/page.html' |
448 | --- edit-here/theme/templates/page.html 2015-02-09 13:40:52 +0000 |
449 | +++ edit-here/theme/templates/page.html 2015-02-24 09:19:38 +0000 |
450 | @@ -1,3 +1,4 @@ |
451 | +{%- if page.lang %}{% set DEFAULT_LANG = page.lang %}{% endif -%} |
452 | {% extends "base.html" %} |
453 | {% block title %}{{ page.title }}{%endblock%} |
454 | {% block content %} |
455 | |
456 | === modified file 'edit-here/translations.py' |
457 | --- edit-here/translations.py 2015-02-20 10:54:43 +0000 |
458 | +++ edit-here/translations.py 2015-02-24 09:19:38 +0000 |
459 | @@ -11,8 +11,16 @@ |
460 | 'title', |
461 | 'lang', |
462 | 'date', |
463 | - 'save_as', |
464 | - 'url', |
465 | + ] |
466 | + |
467 | +# This defines how complete we expect translations to be before we generate |
468 | +# HTML from them. Needs to be string. |
469 | +TRANSLATION_COMPLETION_PERCENTAGE = '0' |
470 | + |
471 | +PO4A_ARGS = [ |
472 | + '-f', 'text', |
473 | + '-o', 'markdown', |
474 | + '-M', 'utf-8', |
475 | ] |
476 | |
477 | |
478 | @@ -20,9 +28,9 @@ |
479 | def __init__(self): |
480 | self._cleanup() |
481 | self.translations_dir = os.path.abspath(os.path.join(PATH, '../po')) |
482 | - self.available_languages = list( |
483 | - map(lambda a: os.path.basename(a).split('.po')[0], |
484 | - glob.glob(self.translations_dir+'/*.po'))) |
485 | + self.available_languages = \ |
486 | + [os.path.basename(a).split('.po')[0] for a |
487 | + in glob.glob(self.translations_dir+'/*.po')] |
488 | self.documents = self._find_documents() |
489 | self.tempdir = tempfile.mkdtemp() |
490 | |
491 | @@ -38,15 +46,15 @@ |
492 | |
493 | def _cleanup(self): |
494 | r = subprocess.Popen(['bzr', 'ignored'], stdout=subprocess.PIPE) |
495 | - files = codecs.decode(r.communicate()[0]).split('\n') |
496 | + files = [os.path.join(PATH, '../..', f.split(' ')[0]) |
497 | + for f in codecs.decode(r.communicate()[0]).split('\n') |
498 | + if f.strip() != ''] |
499 | + files = [f for f in files if os.path.exists(f)] |
500 | for f in files: |
501 | - if f != '': |
502 | - fn = os.path.join(PATH, '../..', f.split(' ')[0]) |
503 | - if os.path.exists(fn): |
504 | - try: |
505 | - shutil.rmtree(fn) |
506 | - except: |
507 | - pass |
508 | + try: |
509 | + shutil.rmtree(f) |
510 | + except NotADirectoryError: |
511 | + os.remove(f) |
512 | |
513 | def _remove_metadata(self, filename): |
514 | new_dir = os.path.join(self.tempdir, os.path.dirname(filename)) |
515 | @@ -58,7 +66,8 @@ |
516 | (x.startswith('Title:') or x.startswith('title:'))] |
517 | index = 0 |
518 | for line in lines: |
519 | - if not [x for x in METADATA_TAGS if line.lower().startswith(x+':')] and \ |
520 | + if not [x for x in METADATA_TAGS |
521 | + if line.lower().startswith(x+':')] and \ |
522 | line.strip() != '': |
523 | index = lines.index(line) |
524 | break |
525 | @@ -79,31 +88,39 @@ |
526 | return True |
527 | |
528 | def generate_pot_file(self): |
529 | - args = [ |
530 | - '-f', 'text', |
531 | - '-o', 'markdown', |
532 | - '-M', 'utf-8', |
533 | - '-L', 'utf-8', |
534 | - ] |
535 | + args = PO4A_ARGS.copy() |
536 | for document in self.documents: |
537 | args += ['-m', document] |
538 | args += [ |
539 | - '-p', os.path.join(self.translations_dir, 'help.pot') |
540 | + '-p', os.path.join(self.translations_dir, 'help.pot'), |
541 | + '-L', 'utf-8', |
542 | ] |
543 | pwd = os.getcwd() |
544 | os.chdir(self.tempdir) |
545 | subprocess.call(['po4a-gettextize']+args) |
546 | os.chdir(pwd) |
547 | |
548 | + def update_po_files(self): |
549 | + pwd = os.getcwd() |
550 | + os.chdir(self.tempdir) |
551 | + for lang in self.available_languages: |
552 | + args = PO4A_ARGS.copy() |
553 | + for document in self.documents: |
554 | + args += ['-m', document] |
555 | + args += ['-p', os.path.join(self.translations_dir, lang+'.po')] |
556 | + ret = subprocess.call(['po4a-updatepo']+args) |
557 | + if ret: |
558 | + return False |
559 | + os.chdir(pwd) |
560 | + return True |
561 | + |
562 | def _call_po4a_translate(self, doc, lang): |
563 | - args = [ |
564 | - '-k', '0', # this defines the percentage of completion |
565 | - '-f', 'text', |
566 | - '-o', 'markdown', |
567 | - '-M', 'utf-8', |
568 | - '-L', 'utf-8', |
569 | + args = PO4A_ARGS.copy() |
570 | + args += [ |
571 | + '-k', TRANSLATION_COMPLETION_PERCENTAGE, |
572 | '-m', doc, |
573 | '-p', 'po/%s.po' % lang, |
574 | + '-L', 'utf-8', |
575 | ] |
576 | res = subprocess.Popen(['po4a-translate']+args, |
577 | stdout=subprocess.PIPE) |
578 | @@ -115,25 +132,24 @@ |
579 | output = '\n'.join(rest) |
580 | return (broken_title_line, output) |
581 | |
582 | - def _new_header(self, lang, doc, broken_title_line): |
583 | + def _new_header(self, lang, broken_title_line): |
584 | title_line = broken_title_line |
585 | for metadata_tag in [x for x in METADATA_TAGS if not x == 'title']: |
586 | title_line = title_line.split(metadata_tag)[0] |
587 | title_line = title_line.split(metadata_tag.capitalize())[0] |
588 | title_line = title_line.split(metadata_tag.upper())[0] |
589 | - save_as = os.path.join('pages', lang, |
590 | - os.path.basename(doc)).replace('.md', '.html') |
591 | - return "Title:%s\nLang: %s\nSave_as: %s\nDate:\nURL:\n\n" % \ |
592 | - (title_line, lang, save_as) |
593 | + return "%s\nLang: %s\nDate:\n\n" % \ |
594 | + (title_line, lang) |
595 | |
596 | def generate_translations(self): |
597 | for lang in self.available_languages: |
598 | for doc in self.documents: |
599 | (broken_title_line, output) = \ |
600 | self._call_po4a_translate(doc, lang) |
601 | - new_path = os.path.join(PATH, 'pages', lang, |
602 | - os.path.basename(doc)) |
603 | - text = self._new_header(lang, doc, broken_title_line) |
604 | + new_path = os.path.join(PATH, 'pages', |
605 | + 'lang-%s-%s' % |
606 | + (lang, os.path.basename(doc))) |
607 | + text = self._new_header(lang, broken_title_line) |
608 | text += output |
609 | if os.path.exists(new_path): |
610 | os.remove(new_path) |
Our Makefile assumes a dirty build:
bzr ignored | cut -d' ' -f1 | xargs rm -r
rm: missing operand
Try 'rm --help' for more information.
Makefile:4: recipe for target 'clean' failed
make: [clean] Error 123 (ignored)
As for this merge, it appears you cloned the english into the german translation? It does indeed generate the proper files, but the linking seems to be off.