Merge lp:~dpm/quickshot/enable-translations into lp:quickshot

Proposed by David Planella
Status: Needs review
Proposed branch: lp:~dpm/quickshot/enable-translations
Merge into: lp:quickshot
Diff against target: 265 lines (+116/-22)
3 files modified
bin/quickshot (+27/-18)
po/quickshot.pot (+87/-2)
quickshot.desktop.in (+2/-2)
To merge this branch: bzr merge lp:~dpm/quickshot/enable-translations
Reviewer Review Type Date Requested Status
Josh Holland (community) Approve
Review via email: mp+25548@code.launchpad.net

Description of the change

This branch provides internationalization support for Quickshot by initializing gettext and marking some remaining strings for translation.

To post a comment you must log in.
Revision history for this message
David Planella (dpm) wrote :

Note that for Quickshot for be properly translatable constructions of this kind should be avoided:

                self.usersetup.label.set_label(''.join((
                 "<b>Save all your work</b> and click the \"Login\" button to ",
                 "logout and login to this new user to start taking ",
                 "screenshots or, if you want to begin at a later time, ",
                 "click \"Close\".",
                )))

That's just one of the several examples in bin/quickshot. For translators to be able to do their work, these strings should be not truncated (and then they should be surrounded by _() to make them translatable).

Revision history for this message
Josh Holland (jshholland) wrote :

This looks good to me, thanks a lot dpm!

review: Approve
Revision history for this message
Neil Tallim (red-hamsterx) wrote :

Thank you for your patch, David.

However, the entire GUI design is set for a rebuild, now that we know what works and what doesn't (a three-week development cycle kinda leads to lots of kludges, like using .join() as a compromise between having super-long strings and developer-side readability). As such, we'll be able to avoid inconsistencies in how we define strings and where we store literal data in the codebase (it'll be a highly modular design, with an emphasis on making it easy to find the right code to change to alter behaviour).

Unfortunately, your contribution likely won't be preserved as we move forward, since we're tearing things down to do them right, but we will be certain to study what you have changed and apply your enhancements throughout every new piece of code that we write.

When we're ready to begin accepting translations in a couple of months, we would greatly appreciate your input on anything we can do better with the new infrastructure, to make the process as easy as possible for would-be contributors.

Revision history for this message
David Planella (dpm) wrote :

El dt 18 de 05 de 2010 a les 20:05 +0000, en/na Neil Tallim va escriure:
> Thank you for your patch, David.
>
> However, the entire GUI design is set for a rebuild, now that we know
> what works and what doesn't (a three-week development cycle kinda
> leads to lots of kludges, like using .join() as a compromise between
> having super-long strings and developer-side readability). As such,
> we'll be able to avoid inconsistencies in how we define strings and
> where we store literal data in the codebase (it'll be a highly modular
> design, with an emphasis on making it easy to find the right code to
> change to alter behaviour).
>
> Unfortunately, your contribution likely won't be preserved as we move
> forward, since we're tearing things down to do them right, but we will
> be certain to study what you have changed and apply your enhancements
> throughout every new piece of code that we write.
>

That's absolutely fine. However, the basic steps for a localizable
application will remain:

* Initialize gettext (the bindtextdomain stuff)
* Mark strings for translation (generally surrounding them with _() or
using ngettext for plurals)

> When we're ready to begin accepting translations in a couple of
> months, we would greatly appreciate your input on anything we can do
> better with the new infrastructure, to make the process as easy as
> possible for would-be contributors.

Sure, feel free to ping me any time and I'll be glad to help in what I
can.

--
David Planella
Ubuntu Translations Coordinator
david(dot)planella(at)ubuntu(dot)com
www.ubuntu.com

Unmerged revisions

244. By David Planella

Marked a few strings for translation

243. By David Planella

Added i18n support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/quickshot'
--- bin/quickshot 2010-04-22 19:12:19 +0000
+++ bin/quickshot 2010-05-18 18:44:25 +0000
@@ -21,6 +21,9 @@
21import logging21import logging
22import optparse22import optparse
23import gtk23import gtk
24import gettext
25_ = gettext.gettext
26ngettext = gettext.ngettext
2427
25# optional Launchpad integration28# optional Launchpad integration
26# this shouldn't crash if not found as it is simply used for bug reporting29# this shouldn't crash if not found as it is simply used for bug reporting
@@ -152,7 +155,7 @@
152 p.wait()155 p.wait()
153 if not '10.04' in p.stdout.read():156 if not '10.04' in p.stdout.read():
154 self.next_1.hide()157 self.next_1.hide()
155 self.builder.get_object('label1').set_text("Welcome, to Quickshot.\n\n The Ubuntu manual requires the screenshots in ubuntu 10.04, \n please see your web browser for more information") 158 self.builder.get_object('label1').set_text(_("Welcome, to Quickshot.\n\n The Ubuntu manual requires the screenshots in ubuntu 10.04, \n please see your web browser for more information"))
156 subprocess.Popen(['sensible-browser', 'https://wiki.ubuntu.com/ubuntu-manual/quickshot/getquickshot'])159 subprocess.Popen(['sensible-browser', 'https://wiki.ubuntu.com/ubuntu-manual/quickshot/getquickshot'])
157160
158161
@@ -195,7 +198,7 @@
195 self.usersetup.show()198 self.usersetup.show()
196 if userutils.checkForUser():199 if userutils.checkForUser():
197 """If the user already exists, skip ahead."""200 """If the user already exists, skip ahead."""
198 self.usersetup.labeltop.set_label(" A \"quickshot\" user already exists.")201 self.usersetup.labeltop.set_label(_(" A \"quickshot\" user already exists."))
199 self.usersetup.table1.hide()202 self.usersetup.table1.hide()
200 self.usersetup.okbutton.hide()203 self.usersetup.okbutton.hide()
201 self.usersetup.label.set_label(''.join((204 self.usersetup.label.set_label(''.join((
@@ -413,7 +416,7 @@
413 subprocess.Popen(["gnome-session-save", "--kill", "--silent"])416 subprocess.Popen(["gnome-session-save", "--kill", "--silent"])
414 #os.system("gnome-session-save --kill --silent")417 #os.system("gnome-session-save --kill --silent")
415 else:418 else:
416 self.builder.get_object('label19').set_text("Remaining:" + str(counter))419 self.builder.get_object('label19').set_text("Remaining: %s" % str(counter))
417420
418 def show_next(self, button , data=None):421 def show_next(self, button , data=None):
419 """button in we can't change resolution window"""422 """button in we can't change resolution window"""
@@ -474,8 +477,8 @@
474477
475 if self.screenshots is None:478 if self.screenshots is None:
476 logging.getLogger().info('Fetching screencap state data from server')479 logging.getLogger().info('Fetching screencap state data from server')
477 self.screenshotdesclabel.set_text("Please wait while the screenshot list is downloaded...")480 self.screenshotdesclabel.set_text(_("Please wait while the screenshot list is downloaded..."))
478 p = ProgressDialog.NewProgressDialog("Retrieving the list of screenshots...")481 p = ProgressDialog.NewProgressDialog(_("Retrieving the list of screenshots..."))
479 p.run_function_async(_update)482 p.run_function_async(_update)
480483
481 if self.screenshots:484 if self.screenshots:
@@ -495,11 +498,11 @@
495 # self.screenshotstore.append([screenshot, "approved for inclusion"])498 # self.screenshotstore.append([screenshot, "approved for inclusion"])
496499
497 if uncaptured:500 if uncaptured:
498 self.screenshotdesclabel.set_text("Click on a screenshot entry in the list above to view a summary and begin capturing")501 self.screenshotdesclabel.set_text(_("Click on a screenshot entry in the list above to view a summary and begin capturing"))
499 else:502 else:
500 self.screenshotdesclabel.set_text("Every screenshot required for your language has been uploaded")503 self.screenshotdesclabel.set_text(_("Every screenshot required for your language has been uploaded"))
501 else:504 else:
502 self.screenshotdesclabel.set_text('Unable to retreve screenshot list from server: reason unknown; see console events')505 self.screenshotdesclabel.set_text(_('Unable to retreve screenshot list from server: reason unknown; see console events'))
503 506
504 def on_screenshotinfo_show(self, sender):507 def on_screenshotinfo_show(self, sender):
505 logging.getLogger().debug('Displaying screenshot information')508 logging.getLogger().debug('Displaying screenshot information')
@@ -538,7 +541,7 @@
538 if "steps" in details:541 if "steps" in details:
539 self.capture_label.set_text(details["steps"])542 self.capture_label.set_text(details["steps"])
540 else:543 else:
541 self.capture_label.set_text("Click \"Capture\" to take the screenshot.")544 self.capture_label.set_text(_("Click \"Capture\" to take the screenshot."))
542545
543 self.screenshotinfo.hide()546 self.screenshotinfo.hide()
544 self.shotcheck.hide()547 self.shotcheck.hide()
@@ -558,7 +561,8 @@
558 561
559 self.capture_timer -= 1562 self.capture_timer -= 1
560 if self.capture_timer > 0:563 if self.capture_timer > 0:
561 self.capture_label.set_text("Taking the screenshot in " + str(self.capture_timer) + " seconds.")564 sec_count = str(self.capture_timer)
565 self.capture_label.set_text(ngettext("Taking the screenshot in %(seconds)s second.", "Taking the screenshot in %(seconds)s seconds.", sec_count) % {'seconds': sec_count})
562 return True566 return True
563 else:567 else:
564 self.capture.hide()568 self.capture.hide()
@@ -592,7 +596,7 @@
592 596
593 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)597 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)
594 #TODO: check for errors598 #TODO: check for errors
595 p = ProgressDialog.NewProgressDialog("Uploading the screenshot...")599 p = ProgressDialog.NewProgressDialog(_("Uploading the screenshot..."))
596 p.run_function_async(quickshot.lib.upload, options.server, {"language": self.get_active_language()[0], "name": name})600 p.run_function_async(quickshot.lib.upload, options.server, {"language": self.get_active_language()[0], "name": name})
597601
598 #add the screenshot to the pending screenshots602 #add the screenshot to the pending screenshots
@@ -619,7 +623,7 @@
619 def on_screenshottreeview_cursor_changed(self, sender):623 def on_screenshottreeview_cursor_changed(self, sender):
620 logging.getLogger().debug('Updating screenshot details')624 logging.getLogger().debug('Updating screenshot details')
621 625
622 self.screenshotdesclabel.set_text("Please wait while screenshot details are downloaded...")626 self.screenshotdesclabel.set_text(_("Please wait while screenshot details are downloaded..."))
623 try:627 try:
624 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)628 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)
625 self.screenshotdetails = quickshot.lib.get_screencap_details(options.server, {"name": name})629 self.screenshotdetails = quickshot.lib.get_screencap_details(options.server, {"name": name})
@@ -650,20 +654,25 @@
650 ui_filename = None654 ui_filename = None
651655
652 builder = gtk.Builder()656 builder = gtk.Builder()
657 builder.set_translation_domain(gettext.textdomain())
653 builder.add_from_file(ui_filename)658 builder.add_from_file(ui_filename)
654 window = builder.get_object("main")659 window = builder.get_object("main")
655 window.finish_initializing(builder)660 window.finish_initializing(builder)
656 return window661 return window
657662
658if __name__ == "__main__":663if __name__ == "__main__":
664 gettext.textdomain('quickshot')
665 gettext.bindtextdomain(gettext.textdomain(), '/usr/share/locale')
666 locale.bindtextdomain(gettext.textdomain(), gettext.bindtextdomain(gettext.textdomain()))
667
659 #support for command line options668 #support for command line options
660 parser = optparse.OptionParser(version="%prog %ver")669 parser = optparse.OptionParser(version="%prog %ver")
661 parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages")670 parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("Show debug messages"))
662 parser.add_option("-r", "--remove", action="store_true", dest="remove", help="Remove quickshot user")671 parser.add_option("-r", "--remove", action="store_true", dest="remove", help=_("Remove quickshot user"))
663 parser.add_option("-n", "--no-change-resolution", action="store_true", dest="no_resolution_change", help="Don't try to change the resolution")672 parser.add_option("-n", "--no-change-resolution", action="store_true", dest="no_resolution_change", help=_("Don't try to change the resolution"))
664 parser.add_option("-s", "--server", action="store", type="string", dest="server", default="http://screenshots.ubuntu-manual.org/", help="The server to use for screenshot data")673 parser.add_option("-s", "--server", action="store", type="string", dest="server", default="http://screenshots.ubuntu-manual.org/", help=_("The server to use for screenshot data"))
665 parser.add_option("--debug", action="store_true", dest="debug_mode", help="Enable debug behaviour and output")674 parser.add_option("--debug", action="store_true", dest="debug_mode", help=_("Enable debug behaviour and output"))
666 parser.add_option("--devel", action="store_true", dest="development_mode", help="Enable development behaviour")675 parser.add_option("--devel", action="store_true", dest="development_mode", help=_("Enable development behaviour"))
667676
668 (options, args) = parser.parse_args()677 (options, args) = parser.parse_args()
669 678
670679
=== modified file 'po/quickshot.pot'
--- po/quickshot.pot 2010-04-22 17:01:44 +0000
+++ po/quickshot.pot 2010-05-18 18:44:25 +0000
@@ -8,13 +8,14 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2010-04-22 19:51+0530\n"11"POT-Creation-Date: 2010-05-18 20:40+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
15"MIME-Version: 1.0\n"15"MIME-Version: 1.0\n"
16"Content-Type: text/plain; charset=CHARSET\n"16"Content-Type: text/plain; charset=CHARSET\n"
17"Content-Transfer-Encoding: 8bit\n"17"Content-Transfer-Encoding: 8bit\n"
18"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
1819
19#: ../data/ui/PreferencesQuickshotDialog.ui.h:120#: ../data/ui/PreferencesQuickshotDialog.ui.h:1
20msgid "gtk-cancel"21msgid "gtk-cancel"
@@ -173,7 +174,7 @@
173"the same password as your main account!</b>\n"174"the same password as your main account!</b>\n"
174msgstr ""175msgstr ""
175176
176#: ../data/ui/QuickshotWindow.ui.h:43177#: ../data/ui/QuickshotWindow.ui.h:43 ../quickshot.desktop.in.h:1
177msgid "Quickshot"178msgid "Quickshot"
178msgstr ""179msgstr ""
179180
@@ -260,3 +261,87 @@
260#: ../data/ui/QuickshotWindow.ui.h:73 ../data/ui/ProgressDialog.ui.h:1261#: ../data/ui/QuickshotWindow.ui.h:73 ../data/ui/ProgressDialog.ui.h:1
261msgid "label"262msgid "label"
262msgstr ""263msgstr ""
264
265#: ../bin/quickshot.py:158
266msgid ""
267"Welcome, to Quickshot.\n"
268"\n"
269" The Ubuntu manual requires the screenshots in ubuntu 10.04, \n"
270" please see your web browser for more information"
271msgstr ""
272
273#: ../bin/quickshot.py:201
274msgid " A \"quickshot\" user already exists."
275msgstr ""
276
277#: ../bin/quickshot.py:480
278msgid "Please wait while the screenshot list is downloaded..."
279msgstr ""
280
281#: ../bin/quickshot.py:481
282msgid "Retrieving the list of screenshots..."
283msgstr ""
284
285#: ../bin/quickshot.py:501
286msgid ""
287"Click on a screenshot entry in the list above to view a summary and begin "
288"capturing"
289msgstr ""
290
291#: ../bin/quickshot.py:503
292msgid "Every screenshot required for your language has been uploaded"
293msgstr ""
294
295#: ../bin/quickshot.py:505
296msgid ""
297"Unable to retreve screenshot list from server: reason unknown; see console "
298"events"
299msgstr ""
300
301#: ../bin/quickshot.py:544
302msgid "Click \"Capture\" to take the screenshot."
303msgstr ""
304
305#: ../bin/quickshot.py:565
306#, python-format
307msgid "Taking the screenshot in %(seconds)s second."
308msgid_plural "Taking the screenshot in %(seconds)s seconds."
309msgstr[0] ""
310msgstr[1] ""
311
312#. TODO: check for errors
313#: ../bin/quickshot.py:599
314msgid "Uploading the screenshot..."
315msgstr ""
316
317#: ../bin/quickshot.py:626
318msgid "Please wait while screenshot details are downloaded..."
319msgstr ""
320
321#: ../bin/quickshot.py:670
322msgid "Show debug messages"
323msgstr ""
324
325#: ../bin/quickshot.py:671
326msgid "Remove quickshot user"
327msgstr ""
328
329#: ../bin/quickshot.py:672
330msgid "Don't try to change the resolution"
331msgstr ""
332
333#: ../bin/quickshot.py:673
334msgid "The server to use for screenshot data"
335msgstr ""
336
337#: ../bin/quickshot.py:674
338msgid "Enable debug behaviour and output"
339msgstr ""
340
341#: ../bin/quickshot.py:675
342msgid "Enable development behaviour"
343msgstr ""
344
345#: ../quickshot.desktop.in.h:2
346msgid "Quickshot application"
347msgstr ""
263348
=== modified file 'quickshot.desktop.in'
--- quickshot.desktop.in 2010-03-25 19:11:42 +0000
+++ quickshot.desktop.in 2010-05-18 18:44:25 +0000
@@ -1,6 +1,6 @@
1[Desktop Entry]1[Desktop Entry]
2Name=Quickshot2_Name=Quickshot
3Comment=Quickshot application3_Comment=Quickshot application
4Categories=GNOME;Utility;4Categories=GNOME;Utility;
5Exec=quickshot5Exec=quickshot
6Icon=/usr/share/quickshot/media/icon.png6Icon=/usr/share/quickshot/media/icon.png

Subscribers

People subscribed via source and target branches

to status/vote changes: