Merge lp:~mitya57/ubuntu-packaging-guide/translator-credits into lp:ubuntu-packaging-guide

Proposed by Dmitry Shachnev
Status: Merged
Merged at revision: 294
Proposed branch: lp:~mitya57/ubuntu-packaging-guide/translator-credits
Merge into: lp:ubuntu-packaging-guide
Diff against target: 390 lines (+238/-12)
10 files modified
.bzrignore (+1/-0)
Makefile (+13/-8)
conf.py (+1/-1)
debian/changelog (+5/-0)
debian/control (+2/-1)
debian/scripts/build-list-of-translators (+109/-0)
debian/scripts/data/template.html (+27/-0)
po/ubuntu-packaging-guide.pot (+5/-2)
themes/ubuntu/layout.html (+3/-0)
themes/ubuntu/static/translators.css (+72/-0)
To merge this branch: bzr merge lp:~mitya57/ubuntu-packaging-guide/translator-credits
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+148710@code.launchpad.net

Description of the change

This branch adds:

- a script that generates a list of translators in .txt or .html formats;
- "Help translate" and "View the list of translators" links to the page bottom.

This should (hopefully) motivate new translators to take part in our project.

Using the script (it's written in Python 3.x, I'll port add-languages to Python 3 also later):

- ./debian/scripts/build-list-of-translators — will create output for supported languages (es and ru) in translators.txt;
- ./debian/scripts/build-list-of-translators -a — will create output for all languages;
- ./debian/scripts/build-list-of-translators -l lv -l ca — will create output for Latvian and Catalan languages.
- ./debian/scripts/build-list-of-translators -o translators.html — will create an HTML file on output. One should also copy style.css from debian/scripts/data to the directory containing that HTML file.

Running the script will print something like this to stdout:

Processing languages: vi ru sv nl sl te(s) ja mk de id it tr en_AU(s) zh_TW lv ca fr es kn(s) zh_HK pt_BR hr hu(s)

(s) means that the language is skipped because the translators list is not available;
(e) means that the given .po file doesn't exist.

This will actually work after first translations update, but I've put an example of generated page to http://people.ubuntu.com/~mitya57/ubuntu-packaging-guide-translators.html.

To post a comment you must log in.
288. By Launchpad Translations on behalf of ubuntu-packaging-guide-team

Launchpad automatic translations update.

289. By Dmitry Shachnev

udd-merging.rst: remove reference, it was moved to udd-intro.rst

290. By Launchpad Translations on behalf of ubuntu-packaging-guide-team

Launchpad automatic translations update.

291. By Launchpad Translations on behalf of ubuntu-packaging-guide-team

Launchpad automatic translations update.

292. By Dmitry Shachnev

Fix header in po/de.po

293. By Dmitry Shachnev

* Add a script to build the list of translators, run it during build.
* Add "Help translate" and "View the list of translators" links to
  layout.html.
* Add a build-dependency on python3-polib, and also prefer python3-sphinx
  to not use two python stacks at the build time.

294. By Dmitry Shachnev

Update .pot file

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Pushed a cleaner patchset, it now installs translators.html along with .css to Sphinx's static directories.

Revision history for this message
Daniel Holbach (dholbach) wrote :

If you build this in current 'raring' do you also get something like this?

dh build --builddirectory=_build
   dh_testdir -O--builddirectory=_build
   dh_auto_configure -O--builddirectory=_build
   debian/rules override_dh_auto_build
make[1]: Entering directory `/tmp/buildd/ubuntu-packaging-guide-0.3.1'
make latexpdf
make[2]: Entering directory `/tmp/buildd/ubuntu-packaging-guide-0.3.1'
Compiling .mo files in po/es/LC_MESSAGES
sphinx-build -Dlanguage=es -b latex -d _build/doctrees . _build/latex/es
Running Sphinx v1.1.3
Making output directory...

Exception occurred:
  File "/usr/lib/python3/dist-packages/sphinx/cmdline.py", line 188, in main
    warningiserror, tags)
  File "/usr/lib/python3/dist-packages/sphinx/application.py", line 102, in __init__
    confoverrides or {}, self.tags)
  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 216, in __init__
    exec(code, config)
  File "/tmp/buildd/ubuntu-packaging-guide-0.3.1/conf.py", line 50, in <module>
    head=open(changelog).readline()
  File "/usr/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 1262: ordinal not in range(128)

review: Needs Information
Revision history for this message
Daniel Holbach (dholbach) wrote :

That's with sphinx 1.1.3+dfsg-5ubuntu1.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Apart from that the change looks great as it is.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Building r291 seems to work fine.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Looks like a side-effect of python-sphinx -> python3-sphinx change.
I'll investigate that tomorrow (writing from phone now), feel free to
revert that part for now.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I can't reproduce the crash in the up-to-date raring pbuilder chroot. William Grant suggested me to try chroot from https://launchpad.net/api/devel/ubuntu/raring/i386, will do that later.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Sorry, commented on wrong MP :(

Revision history for this message
Daniel Holbach (dholbach) wrote :

Ok, found the bug... it was easily fixed by:

=== modified file 'conf.py'
--- conf.py 2013-02-11 09:22:39 +0000
+++ conf.py 2013-02-19 10:42:03 +0000
@@ -11,7 +11,7 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.

-import sys, os, re, glob
+import sys, os, re, glob, codecs

 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -47,7 +47,7 @@

 changelog = "debian/changelog"
 if os.path.exists(changelog):
- head=open(changelog).readline()
+ head=codecs.open(changelog, mode='r', encoding='utf-8').readline()
     match = re.compile(".*\((.*)\).*").match(head)
     if match:
         version = match.group(1)

This was necessary because of "Dražen Lučanin" in debian/changelog. :-)

Pushed the fixed along with yours.

review: Approve
Revision history for this message
Daniel Holbach (dholbach) wrote :

A question: will translators.html be shipped in the packages?

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

> A question: will translators.html be shipped in the packages?

Of course, it already is.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-03-01 03:21:49 +0000
3+++ .bzrignore 2013-02-18 12:37:22 +0000
4@@ -2,3 +2,4 @@
5 po/*
6 !po/*.pot
7 !po/*.po
8+translators.html
9
10=== modified file 'Makefile'
11--- Makefile 2013-02-11 12:36:03 +0000
12+++ Makefile 2013-02-18 12:37:22 +0000
13@@ -44,8 +44,9 @@
14 clean:
15 -rm -rf $(BUILDDIR)/* $(PODIR)/.doctrees \
16 $(foreach lang,$(LANGS),$(PODIR)/$(lang)/)
17+ rm -f translators.html
18
19-html: $(foreach lang,$(LANGS),html-$(lang))
20+html: $(foreach lang,$(LANGS),html-$(lang)) translators.html
21 # Always build an English version, even if there are no .po files.
22 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
23 mv $(BUILDDIR)/html/ubuntu-packaging-guide/*html $(BUILDDIR)/html/
24@@ -61,7 +62,7 @@
25 sed -i 's/ubuntu-packaging-guide\///g' $(BUILDDIR)/html/searchindex.js
26 @echo
27 @echo "Build finished. The HTML pages are in $(BUILDDIR)/html"
28-html-%: locale-%
29+html-%: locale-% translators.html
30 $(SPHINXBUILD) -Dlanguage=$* -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html/$*
31 mv $(BUILDDIR)/html/$*/ubuntu-packaging-guide/*html $(BUILDDIR)/html/$*
32 mv $(BUILDDIR)/html/$*/_sources/ubuntu-packaging-guide/*.txt $(BUILDDIR)/html/$*/_sources/
33@@ -77,16 +78,16 @@
34 @echo
35 @echo "Build finished. The HTML pages are in $(BUILDDIR)/html/$*."
36
37-dirhtml: $(foreach lang,$(LANGS),dirhtml-$(lang))
38+dirhtml: $(foreach lang,$(LANGS),dirhtml-$(lang)) translators.html
39 $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml/en
40 @echo
41 @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml/en"
42-dirhtml-%: locale-%
43+dirhtml-%: locale-% translators.html
44 $(SPHINXBUILD) -Dlanguage=$* -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml/$*
45 @echo
46 @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml/$*."
47
48-singlehtml: $(foreach lang,$(LANGS),singlehtml-$(lang))
49+singlehtml: $(foreach lang,$(LANGS),singlehtml-$(lang)) translators.html
50 $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
51 mv $(BUILDDIR)/singlehtml/ubuntu-packaging-guide/*html $(BUILDDIR)/singlehtml
52 sed -i 's/href="..\//href=".\//g' $(BUILDDIR)/singlehtml/index.html
53@@ -95,7 +96,7 @@
54 sed -i 's/src="..\/_static/src=".\/_static/g' $(BUILDDIR)/singlehtml/index.html
55 @echo
56 @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml"
57-singlehtml-%: locale-%
58+singlehtml-%: locale-% translators.html
59 $(SPHINXBUILD) -Dlanguage=$* -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml/$*
60 mv $(BUILDDIR)/singlehtml/$*/ubuntu-packaging-guide/*html $(BUILDDIR)/singlehtml/$*
61 sed -i 's/href="..\//href=".\//g' $(BUILDDIR)/singlehtml/$*/index.html
62@@ -226,8 +227,10 @@
63
64 gettext:
65 $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(PODIR)/
66- sed -i '/^# [0-9a-f]\{32\}/d' $(PODIR)/ubuntu-packaging-guide.pot
67- @echo
68+ @sed -i '/^# [0-9a-f]\{32\}/d' $(PODIR)/ubuntu-packaging-guide.pot
69+ @echo "# Will be replaced with a list of translators" >> $(PODIR)/ubuntu-packaging-guide.pot
70+ @echo "msgid \"translator-credits\"" >> $(PODIR)/ubuntu-packaging-guide.pot
71+ @echo "msgstr \"\"" >> $(PODIR)/ubuntu-packaging-guide.pot
72 @echo "Build finished. The message catalogs are in $(PODIR)/."
73
74 changes:
75@@ -255,3 +258,5 @@
76 else echo "$*.po not available, skipping .mo building"; \
77 fi
78
79+translators.html:
80+ debian/scripts/build-list-of-translators -a -o translators.html
81
82=== modified file 'conf.py'
83--- conf.py 2013-02-11 09:22:39 +0000
84+++ conf.py 2013-02-18 12:37:22 +0000
85@@ -132,7 +132,7 @@
86 # Add any paths that contain custom static files (such as style sheets) here,
87 # relative to this directory. They are copied after the builtin static files,
88 # so a file named "default.css" will overwrite the builtin "default.css".
89-html_static_path = ['_static']
90+html_static_path = ['_static', 'translators.html']
91
92 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
93 # using the given strftime format.
94
95=== modified file 'debian/changelog'
96--- debian/changelog 2013-02-12 07:08:12 +0000
97+++ debian/changelog 2013-02-18 12:37:22 +0000
98@@ -11,6 +11,11 @@
99 - Add a build-dependency on cm-super-minimal.
100 - Disable times package when language is russian.
101 * Update README and add some information for translators.
102+ * Add a script to build the list of translators, run it during build.
103+ * Add "Help translate" and "View the list of translators" links to
104+ layout.html.
105+ * Add a build-dependency on python3-polib, and also prefer python3-sphinx
106+ to not use two python stacks at the build time.
107
108 [ Daniel Holbach ]
109 * Document where to find a list of required autopkgtests and where
110
111=== modified file 'debian/control'
112--- debian/control 2013-02-11 07:46:42 +0000
113+++ debian/control 2013-02-18 12:37:22 +0000
114@@ -7,7 +7,8 @@
115 Vcs-Browser: https://code.launchpad.net/~ubuntu-packaging-guide-team/ubuntu-packaging-guide/trunk
116 Build-Depends: debhelper (>= 7.0.50~),
117 doc-base,
118- python-sphinx (>= 1.1~),
119+ python3-sphinx | python-sphinx (>= 1.1~),
120+ python3-polib,
121 texlive-fonts-recommended,
122 texlive-latex-recommended,
123 texlive-latex-extra,
124
125=== added file 'debian/scripts/build-list-of-translators'
126--- debian/scripts/build-list-of-translators 1970-01-01 00:00:00 +0000
127+++ debian/scripts/build-list-of-translators 2013-02-18 12:37:22 +0000
128@@ -0,0 +1,109 @@
129+#!/usr/bin/python3
130+
131+# Builds a list in translators for the given languages
132+# Run with "--help" to get more info
133+# Author: Dmitry Shachnev <mitya57@ubuntu.com>, 2013
134+
135+import argparse
136+import sys
137+import fnmatch
138+
139+from os import listdir
140+from os.path import exists, isfile, join, dirname
141+
142+try:
143+ import polib
144+except ImportError:
145+ sys.exit("Error: you should have 'python3-polib' package installed.")
146+
147+def parse_translator_string(translator_string):
148+ """Parses translator string and returns (name, url) tuple."""
149+ name, url = translator_string.rsplit(' ', 1)
150+ return name[2:], url
151+
152+def write_txt(translators, fname):
153+ outputfile = open(fname, 'w')
154+ outputfile.write('Ubuntu Packaging Guide translators\n')
155+ outputfile.write('==================================\n')
156+ for langname in sorted(translators):
157+ outputfile.write('\n' + langname + ' language:\n')
158+ for name, url in translators[langname]:
159+ outputfile.write(' - ' + name + ' <' + url + '>\n')
160+ outputfile.close()
161+
162+def write_html(translators, fname):
163+ templatefile = open(join(dirname(__file__) , 'data', 'template.html'))
164+ template = templatefile.read()
165+ templatefile.close()
166+ content = '<h1>Ubuntu Packaging Guide translators</h1>'
167+ for langname in sorted(translators):
168+ langid = langname.lower().replace('(', '').replace(')', '').replace(' ', '-')
169+ content += '\n<h2 id="' + langid + '">' + langname + ' language</h2>\n<ul>\n'
170+ for name, url in translators[langname]:
171+ content += '<li>' + name + ' &lt;<a href="' + url + '">'
172+ content += url + '</a>&gt;\n'
173+ content += '</ul>'
174+ outputfile = open(fname, 'w')
175+ outputfile.write(template.replace('%CONTENT%', content))
176+ outputfile.close()
177+
178+def main():
179+ parser = argparse.ArgumentParser()
180+ parser.add_argument('-o', '--output-file', default='translators.txt',
181+ help='file to save the output to (default: translators.txt)')
182+ parser.add_argument('-a', '--all-languages', action='store_true',
183+ help='output for all languages (not just accepted ones)')
184+ parser.add_argument('-l', '--language', action='append',
185+ help='output for the given language (can be set multiple times)')
186+ args = parser.parse_args()
187+
188+ languages = None
189+ working_dir = '.'
190+ if not exists('po'):
191+ working_dir = join('..', '..')
192+ if not exists(join(working_dir, 'po')):
193+ sys.exit('Error: "po" directory not found!')
194+
195+ if args.all_languages:
196+ pofiles = fnmatch.filter(listdir(join(working_dir, 'po')), '*.po')
197+ languages = [fname[:-3] for fname in pofiles]
198+ elif args.language:
199+ languages = args.language
200+ else:
201+ if isfile(join(working_dir, 'Makefile')):
202+ makefile = open(join(working_dir, 'Makefile'))
203+ else:
204+ sys.exit('Error: Makefile not found!')
205+ for line in makefile:
206+ if line.startswith('LANGS = '):
207+ languages = line.split()[2:]
208+ makefile.close()
209+ if not languages:
210+ sys.exit('Error: no LANGS set in Makefile!')
211+
212+ translators = {}
213+ sys.stdout.write('Processing languages:')
214+ sys.stdout.flush()
215+ for language in languages:
216+ sys.stdout.write(' ' + language)
217+ sys.stdout.flush()
218+ if not isfile(join(working_dir, 'po', language+'.po')):
219+ sys.stdout.write('(e)')
220+ continue
221+ pofile = polib.pofile(join(working_dir, 'po', language+'.po'))
222+ langname = pofile.header[:pofile.header.find('translation')-1]
223+ for entry in pofile:
224+ if entry.msgid == 'translator-credits' and entry.msgstr:
225+ translators[langname] = map(parse_translator_string,
226+ entry.msgstr.split('\n')[1:])
227+ if langname not in translators:
228+ sys.stdout.write('(s)')
229+
230+ if args.output_file.endswith('.html'):
231+ write_html(translators, args.output_file)
232+ else:
233+ write_txt(translators, args.output_file)
234+ print('\nOutput written as', args.output_file)
235+
236+if __name__ == '__main__':
237+ main()
238
239=== added directory 'debian/scripts/data'
240=== added file 'debian/scripts/data/template.html'
241--- debian/scripts/data/template.html 1970-01-01 00:00:00 +0000
242+++ debian/scripts/data/template.html 2013-02-18 12:37:22 +0000
243@@ -0,0 +1,27 @@
244+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
245+<html>
246+<head>
247+<meta http-equiv="content-type" content="text/html; charset=utf-8">
248+<link rel="stylesheet" type="text/css" href="translators.css">
249+<title>Ubuntu Packaging Guide translators</title>
250+</head>
251+<body>
252+<table class="page-areas">
253+<tr class="area-toppanel">
254+<td>
255+<div class="toppanel">
256+<a href="http://developer.ubuntu.com/" class="dev-link">
257+<img src="images/logo-ubuntu.png" alt="Ubuntu logo">
258+developer
259+</a>
260+</div>
261+</td>
262+</tr>
263+<tr class="area-content"><td>
264+<div class="content">
265+%CONTENT%
266+</div>
267+</td></tr>
268+</table>
269+</body>
270+</html>
271
272=== modified file 'po/ubuntu-packaging-guide.pot'
273--- po/ubuntu-packaging-guide.pot 2013-02-12 07:08:12 +0000
274+++ po/ubuntu-packaging-guide.pot 2013-02-18 12:37:22 +0000
275@@ -8,7 +8,7 @@
276 msgstr ""
277 "Project-Id-Version: ubuntu-packaging-guide 0.3.1\n"
278 "Report-Msgid-Bugs-To: \n"
279-"POT-Creation-Date: 2013-02-12 11:02\n"
280+"POT-Creation-Date: 2013-02-18 16:29\n"
281 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
282 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
283 "Language-Team: LANGUAGE <LL@li.org>\n"
284@@ -2706,7 +2706,7 @@
285 msgid "If you are merging an upstream release into an existing Bazaar branch that has not previously used the UDD layout, ``bzr merge-upstream`` will fail with an error that the tag for the previous upstream version is not available; the merge can't be completed without knowing what base version to merge against. To work around this, create a tag in your existing repository for the last upstream version present there; e.g., if the last Ubuntu release was *1.1-0ubuntu3*, create the tag *upstream-1.1* pointing to the bzr revision you want to use as the tip of the upstream branch."
286 msgstr ""
287
288-#: ../ubuntu-packaging-guide/udd-merging.rst:122
289+#: ../ubuntu-packaging-guide/udd-merging.rst:121
290 msgid "You will need newer versions of ``bzr`` and the ``bzr-builddeb`` for the ``merge`` command to work. Use the versions from Ubuntu 12.04 (Precise) or the development versions from the ``bzr`` PPA. Specifically, you need ``bzr`` version 2.5 beta 5 or newer, and ``bzr-builddeb`` version 2.8.1 or newer. For older versions, use the ``bzr merge-package`` command instead."
291 msgstr ""
292
293@@ -3006,3 +3006,6 @@
294 msgid "Once you've got the source package, you can build it as normal with ``pbuilder-dist`` (or ``pbuilder`` or `sbuild`_)."
295 msgstr ""
296
297+# Will be replaced with a list of translators
298+msgid "translator-credits"
299+msgstr ""
300
301=== modified file 'themes/ubuntu/layout.html'
302--- themes/ubuntu/layout.html 2012-12-24 14:32:47 +0000
303+++ themes/ubuntu/layout.html 2013-02-18 12:37:22 +0000
304@@ -206,6 +206,9 @@
305 src="{{ pathto('_static/images/cc-by-sa.png', 1) }}" /></a>
306 {%- endif %}
307 {%- endif %}
308+ <br />
309+ <a href="http://people.ubuntu.com/~mitya57/ubuntu-packaging-guide-readme.html#translating">Help translate</a> or
310+ <a href="{{ pathto('_static/translators.html', 1) }}">view the list of translators</a>.
311
312 </div>
313 </footer>
314
315=== added file 'themes/ubuntu/static/translators.css'
316--- themes/ubuntu/static/translators.css 1970-01-01 00:00:00 +0000
317+++ themes/ubuntu/static/translators.css 2013-02-18 12:37:22 +0000
318@@ -0,0 +1,72 @@
319+/* Main stylesheet, adopted from WpGen default theme. */
320+/* Author: Dmitry Shachnev <mitya57@ubuntu.com>, 2013 */
321+
322+body {
323+ color: #222;
324+ background: url("images/background-footer.png")
325+ repeat scroll 0 0 #f7f6f5;
326+ margin: 0px;
327+ font-family: "Ubuntu";
328+}
329+
330+a {
331+ color: #dd4814;
332+ text-decoration: none;
333+}
334+
335+a:hover {
336+ text-decoration: underline;
337+}
338+
339+a.dev-link:hover {
340+ text-decoration: none;
341+}
342+
343+.page-areas {
344+ width: 100%;
345+ height: 100%;
346+ top: 0px;
347+ bottom: 0px;
348+}
349+
350+.page-areas td {
351+ padding-left: 5px;
352+ padding-right: 5px;
353+}
354+
355+.area-toppanel {
356+ height: 50px;
357+ background-color: white;
358+ font-size: 130%;
359+}
360+
361+.area-toppanel td {
362+ border-bottom: 2px solid #dd4814;
363+}
364+
365+.area-content {
366+ height: 100%;
367+}
368+
369+.content {
370+ background-color: white;
371+ border: 1px solid #f96;
372+ border-radius: 0.5em;
373+ padding: 0.5em;
374+ padding-top: 0em;
375+ height: 100%;
376+}
377+
378+.content, .toppanel {
379+ margin: 0px auto;
380+ max-width: 800px;
381+}
382+
383+/* Fonts */
384+
385+@font-face {
386+ font-family: 'Ubuntu';
387+ font-style: normal;
388+ font-weight: 400;
389+ src: local('Ubuntu'), url(https://themes.googleusercontent.com/static/fonts/ubuntu/v4/_xyN3apAT_yRRDeqB3sPRg.woff) format('woff');
390+}

Subscribers

People subscribed via source and target branches