Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 113 | ||||
Proposed branch: | lp:~francesco-marella/a4/i18n | ||||
Merge into: | lp:a4 | ||||
Diff against target: |
389 lines (+216/-17) 8 files modified
a4lib/app.py (+10/-6) a4lib/i18n.py (+29/-0) data/a4.desktop.in (+3/-2) data/window_main.glade (+9/-9) po/LINGUAS (+1/-0) po/POTFILES.in (+14/-0) po/POTFILES.skip (+3/-0) po/a4.pot (+147/-0) |
||||
To merge this branch: | bzr merge lp:~francesco-marella/a4/i18n | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Gasparini | Approve | ||
Review via email: mp+50412@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
lp:~francesco-marella/a4/i18n
updated
- 109. By Francesco Marella
-
Add support for i18n
Revision history for this message
Francesco Marella (francesco-marella) wrote : | # |
>
> The old functionalities are ok, and strings are correct. Unfortunately I don't
> know enough the translation engine to make further tests, but to me the code
> is ok.
>
> Just one remark (and a note for the merger), we usually try to keep the code
> clean with some tools.
> A brief test with pep8 gives:
> a4lib/i18n.py:12:1: E302 expected 2 blank lines, found 1
> (It's just one blank line, I guess the one of us that will merge can correct
> this as well)
Fixed, thanks.
lp:~francesco-marella/a4/i18n
updated
- 110. By Francesco Marella
-
i18n: when running from source, fetch the mo files from the build dir
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'a4lib/app.py' |
2 | --- a4lib/app.py 2010-12-30 20:30:01 +0000 |
3 | +++ a4lib/app.py 2011-02-24 16:56:48 +0000 |
4 | @@ -13,6 +13,7 @@ |
5 | from a4lib.presentation import PresentationError, NoMetadataError |
6 | from a4lib.player import GtkCairoPlayer |
7 | from a4lib.editor import Editor |
8 | +import a4lib.i18n |
9 | |
10 | UI_PATHS = ('data', '/usr/local/share/a4/data', '/usr/share/a4/data') |
11 | |
12 | @@ -22,6 +23,7 @@ |
13 | |
14 | def __init__(self): |
15 | self.builder = gtk.Builder() |
16 | + self.builder.set_translation_domain("a4") |
17 | for path in UI_PATHS: |
18 | file_name = os.path.join(path, 'window_main.glade') |
19 | try: |
20 | @@ -81,7 +83,7 @@ |
21 | dialog.destroy() |
22 | except NoMetadataError as error: |
23 | msg = 'No A4 data found into file,\nwould you like to convert this file into an A4 presentation?' |
24 | - dialog = gtk.Dialog('Import', self.gtk_window, |
25 | + dialog = gtk.Dialog(_("Import"), self.gtk_window, |
26 | gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, |
27 | (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, |
28 | gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) |
29 | @@ -142,7 +144,7 @@ |
30 | """Event called when the 'Open' button is clicked.""" |
31 | # Set up the file chooser dialog. |
32 | dialog = gtk.FileChooserDialog( |
33 | - None, None, gtk.FILE_CHOOSER_ACTION_OPEN, ( |
34 | + _("Open a presentation"), None, gtk.FILE_CHOOSER_ACTION_OPEN, ( |
35 | gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
36 | gtk.STOCK_OPEN, gtk.RESPONSE_OK)) |
37 | dialog.set_default_response(gtk.RESPONSE_OK) |
38 | @@ -166,7 +168,7 @@ |
39 | |
40 | def on_save_as_clicked(self, widget): |
41 | dialog = gtk.FileChooserDialog( |
42 | - None, None, gtk.FILE_CHOOSER_ACTION_SAVE, ( |
43 | + _("Save presentation as..."), None, gtk.FILE_CHOOSER_ACTION_SAVE, ( |
44 | gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
45 | gtk.STOCK_SAVE, gtk.RESPONSE_OK)) |
46 | dialog.set_default_response(gtk.RESPONSE_OK) |
47 | @@ -342,15 +344,17 @@ |
48 | dialog = gtk.AboutDialog() |
49 | dialog.set_name('A4') |
50 | dialog.set_version(__version__) |
51 | - dialog.set_comments('A stylish tool to create and view cute presentations.') |
52 | + dialog.set_comments(_('A stylish tool to create and view cute presentations.')) |
53 | dialog.set_website('http://launchpad.net/a4') |
54 | - dialog.set_website_label('A4 website') |
55 | + dialog.set_website_label(_("A4 website")) |
56 | dialog.set_copyright('Copyright (C) 2010 A4 Developers') |
57 | #dialog.set_logo("LOGO_GOES_HERE") |
58 | #dialog.set_icon_from_file("ICON_GOES_HERE") |
59 | #code to automagically fetch authors and license should be used here |
60 | dialog.set_authors(['A4 Developers']) |
61 | - dialog.set_license('A4 is released under the terms of GNU GPL, version 3.') |
62 | + dialog.set_license(_("A4 is released under the terms of GNU GPL, version 3.")) |
63 | + #name surname email of the translator(s) |
64 | + dialog.set_translator_credits(_("translator-credits")) |
65 | dialog.run() |
66 | dialog.destroy() |
67 | |
68 | |
69 | === added file 'a4lib/i18n.py' |
70 | --- a4lib/i18n.py 1970-01-01 00:00:00 +0000 |
71 | +++ a4lib/i18n.py 2011-02-24 16:56:48 +0000 |
72 | @@ -0,0 +1,29 @@ |
73 | +# -*- coding: utf-8 -*- |
74 | + |
75 | +# Copyright 2010 A4 Developers. This software is licensed under the |
76 | +# GNU General Public License version 3 (see the file COPYING). |
77 | + |
78 | +import os |
79 | +import gettext |
80 | +import locale |
81 | + |
82 | +MESSAGES_DIR = "build/mo" |
83 | +if not (os.path.isdir(MESSAGES_DIR) and os.path.exists(MESSAGES_DIR)): |
84 | + MESSAGES_DIR = "/usr/share/locale" |
85 | + |
86 | + |
87 | +def setup_locale_and_gettext(): |
88 | + package_name = 'a4' |
89 | + # Install _() builtin for gettext; always returning unicode objects |
90 | + # also install ngettext() |
91 | + gettext.install(package_name, localedir=MESSAGES_DIR, unicode=True, |
92 | + names=("ngettext",)) |
93 | + locale.bindtextdomain(package_name, MESSAGES_DIR) |
94 | + locale.bind_textdomain_codeset(package_name, "UTF-8") |
95 | + |
96 | + try: |
97 | + locale.setlocale(locale.LC_ALL, "") |
98 | + except locale.Error, e: |
99 | + pass |
100 | + |
101 | +setup_locale_and_gettext() |
102 | |
103 | === renamed file 'data/a4.desktop' => 'data/a4.desktop.in' |
104 | --- data/a4.desktop 2010-08-02 13:02:07 +0000 |
105 | +++ data/a4.desktop.in 2011-02-24 16:56:48 +0000 |
106 | @@ -1,9 +1,10 @@ |
107 | [Desktop Entry] |
108 | Type=Application |
109 | Version=1.0 |
110 | -Name=A4 |
111 | -Comment=A stylish tool to create and view cool presentations |
112 | +_Name=A4 |
113 | +_Comment=A stylish tool to create and view cool presentations |
114 | Icon=a4 |
115 | Exec=a4 |
116 | Terminal=false |
117 | Categories=Office;Presentation; |
118 | +StartupNotify=true |
119 | |
120 | === modified file 'data/window_main.glade' |
121 | --- data/window_main.glade 2011-01-18 17:57:15 +0000 |
122 | +++ data/window_main.glade 2011-02-24 16:56:48 +0000 |
123 | @@ -135,7 +135,7 @@ |
124 | <child> |
125 | <object class="GtkToolButton" id="toolbutton_open"> |
126 | <property name="visible">True</property> |
127 | - <property name="tooltip_markup">Open presentation</property> |
128 | + <property name="tooltip_text" translatable="yes">Open presentation</property> |
129 | <property name="use_underline">True</property> |
130 | <property name="stock_id">gtk-open</property> |
131 | <signal name="clicked" handler="on_open_clicked"/> |
132 | @@ -148,7 +148,7 @@ |
133 | <child> |
134 | <object class="GtkToolButton" id="toolbutton_save"> |
135 | <property name="visible">True</property> |
136 | - <property name="tooltip_markup">Save presentation</property> |
137 | + <property name="tooltip_text" translatable="yes">Save presentation</property> |
138 | <property name="use_underline">True</property> |
139 | <property name="stock_id">gtk-save</property> |
140 | <signal name="clicked" handler="on_save_clicked"/> |
141 | @@ -161,7 +161,7 @@ |
142 | <child> |
143 | <object class="GtkToolButton" id="toolbutton_close"> |
144 | <property name="visible">True</property> |
145 | - <property name="tooltip_markup">Close presentation</property> |
146 | + <property name="tooltip_text" translatable="yes">Close presentation</property> |
147 | <property name="use_underline">True</property> |
148 | <property name="stock_id">gtk-close</property> |
149 | <signal name="clicked" handler="on_close_clicked"/> |
150 | @@ -183,7 +183,7 @@ |
151 | <child> |
152 | <object class="GtkToolButton" id="toolbutton_previous"> |
153 | <property name="visible">True</property> |
154 | - <property name="tooltip_markup">Previous view</property> |
155 | + <property name="tooltip_text" translatable="yes">Previous view</property> |
156 | <property name="use_underline">True</property> |
157 | <property name="stock_id">gtk-go-back</property> |
158 | <signal name="clicked" handler="on_previous_clicked"/> |
159 | @@ -196,7 +196,7 @@ |
160 | <child> |
161 | <object class="GtkToolButton" id="toolbutton_next"> |
162 | <property name="visible">True</property> |
163 | - <property name="tooltip_markup">Next view</property> |
164 | + <property name="tooltip_text" translatable="yes">Next view</property> |
165 | <property name="use_underline">True</property> |
166 | <property name="stock_id">gtk-go-forward</property> |
167 | <signal name="clicked" handler="on_next_clicked"/> |
168 | @@ -218,7 +218,7 @@ |
169 | <child> |
170 | <object class="GtkToolButton" id="toolbutton_zoom_in"> |
171 | <property name="visible">True</property> |
172 | - <property name="tooltip_markup">Zoom in</property> |
173 | + <property name="tooltip_text" translatable="yes">Zoom in</property> |
174 | <property name="use_underline">True</property> |
175 | <property name="stock_id">gtk-zoom-in</property> |
176 | <signal name="clicked" handler="on_zoom_in_clicked"/> |
177 | @@ -231,7 +231,7 @@ |
178 | <child> |
179 | <object class="GtkToolButton" id="toolbutton_zoom_out"> |
180 | <property name="visible">True</property> |
181 | - <property name="tooltip_markup">Zoom out</property> |
182 | + <property name="tooltip_text" translatable="yes">Zoom out</property> |
183 | <property name="use_underline">True</property> |
184 | <property name="stock_id">gtk-zoom-out</property> |
185 | <signal name="clicked" handler="on_zoom_out_clicked"/> |
186 | @@ -244,7 +244,7 @@ |
187 | <child> |
188 | <object class="GtkToolButton" id="toolbutton_fullscreen"> |
189 | <property name="visible">True</property> |
190 | - <property name="tooltip_markup">Fullscreen</property> |
191 | + <property name="tooltip_text" translatable="yes">Fullscreen</property> |
192 | <property name="use_underline">True</property> |
193 | <property name="stock_id">gtk-fullscreen</property> |
194 | <signal name="clicked" handler="on_fullscreen_activate"/> |
195 | @@ -285,7 +285,7 @@ |
196 | <child> |
197 | <object class="GtkToggleToolButton" id="toolbutton_editor"> |
198 | <property name="visible">True</property> |
199 | - <property name="tooltip_markup">Editor</property> |
200 | + <property name="tooltip_text" translatable="yes">Editor</property> |
201 | <property name="use_underline">True</property> |
202 | <property name="stock_id">gtk-edit</property> |
203 | <signal name="clicked" handler="on_editor_clicked"/> |
204 | |
205 | === added directory 'po' |
206 | === added file 'po/LINGUAS' |
207 | --- po/LINGUAS 1970-01-01 00:00:00 +0000 |
208 | +++ po/LINGUAS 2011-02-24 16:56:48 +0000 |
209 | @@ -0,0 +1,1 @@ |
210 | +# Set of available languages. Keep it alphabatical. One lingua per line. |
211 | |
212 | === added file 'po/POTFILES.in' |
213 | --- po/POTFILES.in 1970-01-01 00:00:00 +0000 |
214 | +++ po/POTFILES.in 2011-02-24 16:56:48 +0000 |
215 | @@ -0,0 +1,14 @@ |
216 | +# encoding: UTF-8 |
217 | + |
218 | +# order: data files, modules, others |
219 | + |
220 | +data/a4.desktop.in |
221 | + |
222 | +[type: gettext/glade] data/window_main.glade |
223 | + |
224 | +a4lib/app.py |
225 | +a4lib/editor.py |
226 | +a4lib/player.py |
227 | +a4lib/presentation_objects.py |
228 | +a4lib/presentation.py |
229 | +a4lib/region.py |
230 | |
231 | === added file 'po/POTFILES.skip' |
232 | --- po/POTFILES.skip 1970-01-01 00:00:00 +0000 |
233 | +++ po/POTFILES.skip 2011-02-24 16:56:48 +0000 |
234 | @@ -0,0 +1,3 @@ |
235 | +# files to skip |
236 | + |
237 | +a4lib/__init__.py |
238 | |
239 | === added file 'po/a4.pot' |
240 | --- po/a4.pot 1970-01-01 00:00:00 +0000 |
241 | +++ po/a4.pot 2011-02-24 16:56:48 +0000 |
242 | @@ -0,0 +1,147 @@ |
243 | +# SOME DESCRIPTIVE TITLE. |
244 | +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
245 | +# This file is distributed under the same license as the PACKAGE package. |
246 | +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
247 | +# |
248 | +#, fuzzy |
249 | +msgid "" |
250 | +msgstr "" |
251 | +"Project-Id-Version: PACKAGE VERSION\n" |
252 | +"Report-Msgid-Bugs-To: \n" |
253 | +"POT-Creation-Date: 2011-01-26 17:23+0100\n" |
254 | +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
255 | +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
256 | +"Language-Team: LANGUAGE <LL@li.org>\n" |
257 | +"Language: \n" |
258 | +"MIME-Version: 1.0\n" |
259 | +"Content-Type: text/plain; charset=CHARSET\n" |
260 | +"Content-Transfer-Encoding: 8bit\n" |
261 | + |
262 | +#: ../data/a4.desktop.in.h:1 |
263 | +msgid "A stylish tool to create and view cool presentations" |
264 | +msgstr "" |
265 | + |
266 | +#: ../data/a4.desktop.in.h:2 ../data/window_main.glade.h:1 |
267 | +msgid "A4" |
268 | +msgstr "" |
269 | + |
270 | +#: ../data/window_main.glade.h:2 |
271 | +msgid "Close presentation" |
272 | +msgstr "" |
273 | + |
274 | +#: ../data/window_main.glade.h:3 |
275 | +msgid "Editor" |
276 | +msgstr "" |
277 | + |
278 | +#: ../data/window_main.glade.h:4 |
279 | +msgid "Frames" |
280 | +msgstr "" |
281 | + |
282 | +#: ../data/window_main.glade.h:5 |
283 | +msgid "Fullscreen" |
284 | +msgstr "" |
285 | + |
286 | +#: ../data/window_main.glade.h:6 |
287 | +msgid "Hidden Frame" |
288 | +msgstr "" |
289 | + |
290 | +#: ../data/window_main.glade.h:7 |
291 | +msgid "Image" |
292 | +msgstr "" |
293 | + |
294 | +#: ../data/window_main.glade.h:8 |
295 | +msgid "Next view" |
296 | +msgstr "" |
297 | + |
298 | +#: ../data/window_main.glade.h:9 |
299 | +msgid "Normal frame" |
300 | +msgstr "" |
301 | + |
302 | +#: ../data/window_main.glade.h:10 |
303 | +msgid "Notes" |
304 | +msgstr "" |
305 | + |
306 | +#: ../data/window_main.glade.h:11 |
307 | +msgid "Open presentation" |
308 | +msgstr "" |
309 | + |
310 | +#: ../data/window_main.glade.h:12 |
311 | +msgid "Path" |
312 | +msgstr "" |
313 | + |
314 | +#: ../data/window_main.glade.h:13 |
315 | +msgid "Polaroid" |
316 | +msgstr "" |
317 | + |
318 | +#: ../data/window_main.glade.h:14 |
319 | +msgid "Previous view" |
320 | +msgstr "" |
321 | + |
322 | +#: ../data/window_main.glade.h:15 |
323 | +msgid "Rect" |
324 | +msgstr "" |
325 | + |
326 | +#: ../data/window_main.glade.h:16 |
327 | +msgid "Save presentation" |
328 | +msgstr "" |
329 | + |
330 | +#: ../data/window_main.glade.h:17 |
331 | +msgid "Selector" |
332 | +msgstr "" |
333 | + |
334 | +#: ../data/window_main.glade.h:18 |
335 | +msgid "Shapes" |
336 | +msgstr "" |
337 | + |
338 | +#: ../data/window_main.glade.h:19 |
339 | +msgid "Text" |
340 | +msgstr "" |
341 | + |
342 | +#: ../data/window_main.glade.h:20 |
343 | +msgid "Zoom in" |
344 | +msgstr "" |
345 | + |
346 | +#: ../data/window_main.glade.h:21 |
347 | +msgid "Zoom out" |
348 | +msgstr "" |
349 | + |
350 | +#: ../data/window_main.glade.h:22 |
351 | +msgid "_File" |
352 | +msgstr "" |
353 | + |
354 | +#: ../data/window_main.glade.h:23 |
355 | +msgid "_Help" |
356 | +msgstr "" |
357 | + |
358 | +#: ../data/window_main.glade.h:24 |
359 | +msgid "_View" |
360 | +msgstr "" |
361 | + |
362 | +#: ../a4lib/app.py:86 |
363 | +msgid "Import" |
364 | +msgstr "" |
365 | + |
366 | +#: ../a4lib/app.py:147 |
367 | +msgid "Open a presentation" |
368 | +msgstr "" |
369 | + |
370 | +#: ../a4lib/app.py:171 |
371 | +msgid "Save presentation as..." |
372 | +msgstr "" |
373 | + |
374 | +#: ../a4lib/app.py:347 |
375 | +msgid "A stylish tool to create and view cute presentations." |
376 | +msgstr "" |
377 | + |
378 | +#: ../a4lib/app.py:349 |
379 | +msgid "A4 website" |
380 | +msgstr "" |
381 | + |
382 | +#: ../a4lib/app.py:355 |
383 | +msgid "A4 is released under the terms of GNU GPL, version 3." |
384 | +msgstr "" |
385 | + |
386 | +#. name surname email of the translator(s) |
387 | +#: ../a4lib/app.py:357 |
388 | +msgid "translator-credits" |
389 | +msgstr "" |
The old functionalities are ok, and strings are correct. Unfortunately I don't know enough the translation engine to make further tests, but to me the code is ok.
Just one remark (and a note for the merger), we usually try to keep the code clean with some tools.
A brief test with pep8 gives:
a4lib/i18n.py:12:1: E302 expected 2 blank lines, found 1
(It's just one blank line, I guess the one of us that will merge can correct this as well)