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
1=== modified file 'bin/quickshot'
2--- bin/quickshot 2010-04-22 19:12:19 +0000
3+++ bin/quickshot 2010-05-18 18:44:25 +0000
4@@ -21,6 +21,9 @@
5 import logging
6 import optparse
7 import gtk
8+import gettext
9+_ = gettext.gettext
10+ngettext = gettext.ngettext
11
12 # optional Launchpad integration
13 # this shouldn't crash if not found as it is simply used for bug reporting
14@@ -152,7 +155,7 @@
15 p.wait()
16 if not '10.04' in p.stdout.read():
17 self.next_1.hide()
18- 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")
19+ 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"))
20 subprocess.Popen(['sensible-browser', 'https://wiki.ubuntu.com/ubuntu-manual/quickshot/getquickshot'])
21
22
23@@ -195,7 +198,7 @@
24 self.usersetup.show()
25 if userutils.checkForUser():
26 """If the user already exists, skip ahead."""
27- self.usersetup.labeltop.set_label(" A \"quickshot\" user already exists.")
28+ self.usersetup.labeltop.set_label(_(" A \"quickshot\" user already exists."))
29 self.usersetup.table1.hide()
30 self.usersetup.okbutton.hide()
31 self.usersetup.label.set_label(''.join((
32@@ -413,7 +416,7 @@
33 subprocess.Popen(["gnome-session-save", "--kill", "--silent"])
34 #os.system("gnome-session-save --kill --silent")
35 else:
36- self.builder.get_object('label19').set_text("Remaining:" + str(counter))
37+ self.builder.get_object('label19').set_text("Remaining: %s" % str(counter))
38
39 def show_next(self, button , data=None):
40 """button in we can't change resolution window"""
41@@ -474,8 +477,8 @@
42
43 if self.screenshots is None:
44 logging.getLogger().info('Fetching screencap state data from server')
45- self.screenshotdesclabel.set_text("Please wait while the screenshot list is downloaded...")
46- p = ProgressDialog.NewProgressDialog("Retrieving the list of screenshots...")
47+ self.screenshotdesclabel.set_text(_("Please wait while the screenshot list is downloaded..."))
48+ p = ProgressDialog.NewProgressDialog(_("Retrieving the list of screenshots..."))
49 p.run_function_async(_update)
50
51 if self.screenshots:
52@@ -495,11 +498,11 @@
53 # self.screenshotstore.append([screenshot, "approved for inclusion"])
54
55 if uncaptured:
56- self.screenshotdesclabel.set_text("Click on a screenshot entry in the list above to view a summary and begin capturing")
57+ self.screenshotdesclabel.set_text(_("Click on a screenshot entry in the list above to view a summary and begin capturing"))
58 else:
59- self.screenshotdesclabel.set_text("Every screenshot required for your language has been uploaded")
60+ self.screenshotdesclabel.set_text(_("Every screenshot required for your language has been uploaded"))
61 else:
62- self.screenshotdesclabel.set_text('Unable to retreve screenshot list from server: reason unknown; see console events')
63+ self.screenshotdesclabel.set_text(_('Unable to retreve screenshot list from server: reason unknown; see console events'))
64
65 def on_screenshotinfo_show(self, sender):
66 logging.getLogger().debug('Displaying screenshot information')
67@@ -538,7 +541,7 @@
68 if "steps" in details:
69 self.capture_label.set_text(details["steps"])
70 else:
71- self.capture_label.set_text("Click \"Capture\" to take the screenshot.")
72+ self.capture_label.set_text(_("Click \"Capture\" to take the screenshot."))
73
74 self.screenshotinfo.hide()
75 self.shotcheck.hide()
76@@ -558,7 +561,8 @@
77
78 self.capture_timer -= 1
79 if self.capture_timer > 0:
80- self.capture_label.set_text("Taking the screenshot in " + str(self.capture_timer) + " seconds.")
81+ sec_count = str(self.capture_timer)
82+ 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})
83 return True
84 else:
85 self.capture.hide()
86@@ -592,7 +596,7 @@
87
88 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)
89 #TODO: check for errors
90- p = ProgressDialog.NewProgressDialog("Uploading the screenshot...")
91+ p = ProgressDialog.NewProgressDialog(_("Uploading the screenshot..."))
92 p.run_function_async(quickshot.lib.upload, options.server, {"language": self.get_active_language()[0], "name": name})
93
94 #add the screenshot to the pending screenshots
95@@ -619,7 +623,7 @@
96 def on_screenshottreeview_cursor_changed(self, sender):
97 logging.getLogger().debug('Updating screenshot details')
98
99- self.screenshotdesclabel.set_text("Please wait while screenshot details are downloaded...")
100+ self.screenshotdesclabel.set_text(_("Please wait while screenshot details are downloaded..."))
101 try:
102 name = self.screenshotstore.get_value(self.screenshottreeview.get_selection().get_selected()[1], 0)
103 self.screenshotdetails = quickshot.lib.get_screencap_details(options.server, {"name": name})
104@@ -650,20 +654,25 @@
105 ui_filename = None
106
107 builder = gtk.Builder()
108+ builder.set_translation_domain(gettext.textdomain())
109 builder.add_from_file(ui_filename)
110 window = builder.get_object("main")
111 window.finish_initializing(builder)
112 return window
113
114 if __name__ == "__main__":
115+ gettext.textdomain('quickshot')
116+ gettext.bindtextdomain(gettext.textdomain(), '/usr/share/locale')
117+ locale.bindtextdomain(gettext.textdomain(), gettext.bindtextdomain(gettext.textdomain()))
118+
119 #support for command line options
120 parser = optparse.OptionParser(version="%prog %ver")
121- parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages")
122- parser.add_option("-r", "--remove", action="store_true", dest="remove", help="Remove quickshot user")
123- parser.add_option("-n", "--no-change-resolution", action="store_true", dest="no_resolution_change", help="Don't try to change the resolution")
124- 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")
125- parser.add_option("--debug", action="store_true", dest="debug_mode", help="Enable debug behaviour and output")
126- parser.add_option("--devel", action="store_true", dest="development_mode", help="Enable development behaviour")
127+ parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("Show debug messages"))
128+ parser.add_option("-r", "--remove", action="store_true", dest="remove", help=_("Remove quickshot user"))
129+ parser.add_option("-n", "--no-change-resolution", action="store_true", dest="no_resolution_change", help=_("Don't try to change the resolution"))
130+ 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"))
131+ parser.add_option("--debug", action="store_true", dest="debug_mode", help=_("Enable debug behaviour and output"))
132+ parser.add_option("--devel", action="store_true", dest="development_mode", help=_("Enable development behaviour"))
133
134 (options, args) = parser.parse_args()
135
136
137=== modified file 'po/quickshot.pot'
138--- po/quickshot.pot 2010-04-22 17:01:44 +0000
139+++ po/quickshot.pot 2010-05-18 18:44:25 +0000
140@@ -8,13 +8,14 @@
141 msgstr ""
142 "Project-Id-Version: PACKAGE VERSION\n"
143 "Report-Msgid-Bugs-To: \n"
144-"POT-Creation-Date: 2010-04-22 19:51+0530\n"
145+"POT-Creation-Date: 2010-05-18 20:40+0200\n"
146 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
147 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
148 "Language-Team: LANGUAGE <LL@li.org>\n"
149 "MIME-Version: 1.0\n"
150 "Content-Type: text/plain; charset=CHARSET\n"
151 "Content-Transfer-Encoding: 8bit\n"
152+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
153
154 #: ../data/ui/PreferencesQuickshotDialog.ui.h:1
155 msgid "gtk-cancel"
156@@ -173,7 +174,7 @@
157 "the same password as your main account!</b>\n"
158 msgstr ""
159
160-#: ../data/ui/QuickshotWindow.ui.h:43
161+#: ../data/ui/QuickshotWindow.ui.h:43 ../quickshot.desktop.in.h:1
162 msgid "Quickshot"
163 msgstr ""
164
165@@ -260,3 +261,87 @@
166 #: ../data/ui/QuickshotWindow.ui.h:73 ../data/ui/ProgressDialog.ui.h:1
167 msgid "label"
168 msgstr ""
169+
170+#: ../bin/quickshot.py:158
171+msgid ""
172+"Welcome, to Quickshot.\n"
173+"\n"
174+" The Ubuntu manual requires the screenshots in ubuntu 10.04, \n"
175+" please see your web browser for more information"
176+msgstr ""
177+
178+#: ../bin/quickshot.py:201
179+msgid " A \"quickshot\" user already exists."
180+msgstr ""
181+
182+#: ../bin/quickshot.py:480
183+msgid "Please wait while the screenshot list is downloaded..."
184+msgstr ""
185+
186+#: ../bin/quickshot.py:481
187+msgid "Retrieving the list of screenshots..."
188+msgstr ""
189+
190+#: ../bin/quickshot.py:501
191+msgid ""
192+"Click on a screenshot entry in the list above to view a summary and begin "
193+"capturing"
194+msgstr ""
195+
196+#: ../bin/quickshot.py:503
197+msgid "Every screenshot required for your language has been uploaded"
198+msgstr ""
199+
200+#: ../bin/quickshot.py:505
201+msgid ""
202+"Unable to retreve screenshot list from server: reason unknown; see console "
203+"events"
204+msgstr ""
205+
206+#: ../bin/quickshot.py:544
207+msgid "Click \"Capture\" to take the screenshot."
208+msgstr ""
209+
210+#: ../bin/quickshot.py:565
211+#, python-format
212+msgid "Taking the screenshot in %(seconds)s second."
213+msgid_plural "Taking the screenshot in %(seconds)s seconds."
214+msgstr[0] ""
215+msgstr[1] ""
216+
217+#. TODO: check for errors
218+#: ../bin/quickshot.py:599
219+msgid "Uploading the screenshot..."
220+msgstr ""
221+
222+#: ../bin/quickshot.py:626
223+msgid "Please wait while screenshot details are downloaded..."
224+msgstr ""
225+
226+#: ../bin/quickshot.py:670
227+msgid "Show debug messages"
228+msgstr ""
229+
230+#: ../bin/quickshot.py:671
231+msgid "Remove quickshot user"
232+msgstr ""
233+
234+#: ../bin/quickshot.py:672
235+msgid "Don't try to change the resolution"
236+msgstr ""
237+
238+#: ../bin/quickshot.py:673
239+msgid "The server to use for screenshot data"
240+msgstr ""
241+
242+#: ../bin/quickshot.py:674
243+msgid "Enable debug behaviour and output"
244+msgstr ""
245+
246+#: ../bin/quickshot.py:675
247+msgid "Enable development behaviour"
248+msgstr ""
249+
250+#: ../quickshot.desktop.in.h:2
251+msgid "Quickshot application"
252+msgstr ""
253
254=== modified file 'quickshot.desktop.in'
255--- quickshot.desktop.in 2010-03-25 19:11:42 +0000
256+++ quickshot.desktop.in 2010-05-18 18:44:25 +0000
257@@ -1,6 +1,6 @@
258 [Desktop Entry]
259-Name=Quickshot
260-Comment=Quickshot application
261+_Name=Quickshot
262+_Comment=Quickshot application
263 Categories=GNOME;Utility;
264 Exec=quickshot
265 Icon=/usr/share/quickshot/media/icon.png

Subscribers

People subscribed via source and target branches

to status/vote changes: