Merge lp:~dobey/unity-scope-click/translated into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 202
Merged at revision: 209
Proposed branch: lp:~dobey/unity-scope-click/translated
Merge into: lp:unity-scope-click
Diff against target: 297 lines (+114/-16)
11 files modified
CMakeLists.txt (+1/-0)
debian/control (+2/-0)
debian/rules (+1/-1)
po/CMakeLists.txt (+36/-0)
po/POTFILES.in (+1/-0)
po/genpotfiles.sh (+6/-0)
scope/click/CMakeLists.txt (+5/-0)
scope/click/click-i18n.h (+37/-0)
scope/click/preview.cpp (+15/-13)
scope/click/query.cpp (+4/-2)
scope/click/scope.cpp (+6/-0)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/translated
Reviewer Review Type Date Requested Status
David Planella (community) Approve
PS Jenkins bot continuous-integration Approve
Alejandro J. Cura (community) Approve
Michal Hruby (community) Needs Information
Review via email: mp+214182@code.launchpad.net

Commit message

Add the _ macro definition.
Mark strings for translation.
Add build system support for translating the scope.
Add build dependency on intltool.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Isn't this missing calls to setlocale() and bindtextdomain()?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
201. By dobey

Add setlocale/bindtextdomain calls to enable the translations at runtime.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good to me. +1

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

Looks good to me two, just a couple of things:

216 + {"label", scopes::Variant(_("Yes Uninstall"))}

Should this not be "Yes, uninstall"?

I understand this adds i18n support to the scope itself, but how are the translations of the app's desktop files in the dash page that shows the list of all apps going to be handled?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

> Looks good to me two, just a couple of things:
>
> 216 + {"label", scopes::Variant(_("Yes Uninstall"))}
>
> Should this not be "Yes, uninstall"?
>
> I understand this adds i18n support to the scope itself, but how are the
> translations of the app's desktop files in the dash page that shows the list
> of all apps going to be handled?

For installed apps, we plan to take the values from the .desktop file.
For apps in the store, we plan to send a Language header in the http request to the store webservices.
Both will come in further branches.

Revision history for this message
dobey (dobey) wrote :

> Looks good to me two, just a couple of things:
>
> 216 + {"label", scopes::Variant(_("Yes Uninstall"))}
>
> Should this not be "Yes, uninstall"?

The purpose of this branch isn't to change or correct strings, only to add the _() to existing ones. Hopefully next week we'll be deleting the preview that has this string anyway, so it will just go away.

> I understand this adds i18n support to the scope itself, but how are the
> translations of the app's desktop files in the dash page that shows the list
> of all apps going to be handled?

Pulling translations from installed click packages, or from the store, is a much more difficult thing to do, and this branch does not do that. Really, we will need translations for clicks to be in the manifest, so that we can use the translations while offline. Loading the translation domain for every installed program is also very expensive, so we really need to have those translations directly in the .desktop file. We need to discuss implementation details about that on a wider scale, so we can then fix the translations to work for packages as well as the scope itself.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

> 216 + {"label", scopes::Variant(_("Yes Uninstall"))}
>
> Should this not be "Yes, uninstall"?

That string is bug #1234211; it was like that on the design documents and we (devs) agree it looks horrible. I'll re-check again to see if we have a better wording.

202. By dobey

Add use of dh-translations to package build.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

That answered my questions, LGTM!

For translations to be exposed in the upstream project and shared with the source package, I recommend committing the .pot file to the source tree, as we do with other Ubuntu upstreams. Launchpad does not support .pot autogeneration for cmake projects, so to enable automatic translation imports and exports, the .pot file has to be present in the source tree for LP.

For translations in the source package, dh-translations should already take care of everything.

review: Approve
Revision history for this message
dobey (dobey) wrote :

> For translations to be exposed in the upstream project and shared with the
> source package, I recommend committing the .pot file to the source tree, as we
> do with other Ubuntu upstreams. Launchpad does not support .pot autogeneration
> for cmake projects, so to enable automatic translation imports and exports,
> the .pot file has to be present in the source tree for LP.
>
> For translations in the source package, dh-translations should already take
> care of everything.

We won't be using LP translations on the upstream project, only on the package. We don't need to have 2 places to pull and then manually try to consolidate them. So we'll just rely on dh-translations and pulling the .po files from the Ubuntu translations once they are translated.

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

Note that there is no need to do manual work if you enable translations in
the upstream project. With translations sharing, translations done either
upstream or on the source package flow in either direction. Thus developers
don't even have to care. Adding automatic imports and exports gives the
benefit of having translations committed automatically upstream, regardless
of where they are done.

On the contrary, if you only enable translations in the source package
that's where you'll have to do manual work to get those translations back
to upstream: you'll need to request an export from LP, wait for an e-mail
with a zipped export and then manually commit those .po files to upstream.

Thus my recommendation is always to go for the first, which for developers
it's just a matter of committing the .pot file and then the rest works.

Cheers,
David.

On Wed, Apr 9, 2014 at 4:02 PM, Rodney Dawes <email address hidden>wrote:

> The proposal to merge lp:~dobey/unity-scope-click/translated into
> lp:unity-scope-click has been updated.
>
> Status: Needs review => Approved
>
> For more details, see:
>
> https://code.launchpad.net/~dobey/unity-scope-click/translated/+merge/214182
> --
>
> https://code.launchpad.net/~dobey/unity-scope-click/translated/+merge/214182
> You are reviewing the proposed merge of
> lp:~dobey/unity-scope-click/translated into lp:unity-scope-click.
>

Revision history for this message
dobey (dobey) wrote :

On Wed, 2014-04-09 at 14:27 +0000, David Planella wrote:
> Note that there is no need to do manual work if you enable translations in
> the upstream project. With translations sharing, translations done either
> upstream or on the source package flow in either direction. Thus developers
> don't even have to care. Adding automatic imports and exports gives the
> benefit of having translations committed automatically upstream, regardless
> of where they are done.

Unfortunately, it means keeping a generated file in version control, a
file which can oft easily result in conflicts when working on the
project. For projects with very little development, and/or very few
contributors, it's an OK option, because the potential for conflict is
limited, and it means getting new translations without worry. However,
it still means Launchpad is committing directly to the tree, without
warning, and that itself can result in annoyances that result in "manual
work" to resolve conflicts or criss-cross merge problems. Also, it means
having complex rules in the build system, so that the .pot file is
always properly updated in the source tree, as the template is generated
in the build tree, not the source tree, and the recommended way to use
cmake is to do builds under a separate build directory.

Even with the pot file in the tree, and Launchpad automatically
importing that, I don't think we'd want to have Launchpad committing
directly to the tree, so we'd still need to do manual imports of the
translations to the tree.

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

I don't want to keep arguing on this one, so I'll just add for the sake of
completion that Launchpad only commits .po files to the tree, it doesn't
update any other files.

On Wed, Apr 9, 2014 at 4:45 PM, Rodney Dawes <email address hidden>wrote:

> On Wed, 2014-04-09 at 14:27 +0000, David Planella wrote:
> > Note that there is no need to do manual work if you enable translations
> in
> > the upstream project. With translations sharing, translations done either
> > upstream or on the source package flow in either direction. Thus
> developers
> > don't even have to care. Adding automatic imports and exports gives the
> > benefit of having translations committed automatically upstream,
> regardless
> > of where they are done.
>
> Unfortunately, it means keeping a generated file in version control, a
> file which can oft easily result in conflicts when working on the
> project. For projects with very little development, and/or very few
> contributors, it's an OK option, because the potential for conflict is
> limited, and it means getting new translations without worry. However,
> it still means Launchpad is committing directly to the tree, without
> warning, and that itself can result in annoyances that result in "manual
> work" to resolve conflicts or criss-cross merge problems. Also, it means
> having complex rules in the build system, so that the .pot file is
> always properly updated in the source tree, as the template is generated
> in the build tree, not the source tree, and the recommended way to use
> cmake is to do builds under a separate build directory.
>
> Even with the pot file in the tree, and Launchpad automatically
> importing that, I don't think we'd want to have Launchpad committing
> directly to the tree, so we'd still need to do manual imports of the
> translations to the tree.
>
>
>
> --
>
> https://code.launchpad.net/~dobey/unity-scope-click/translated/+merge/214182
> You are reviewing the proposed merge of
> lp:~dobey/unity-scope-click/translated into lp:unity-scope-click.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-03-24 14:04:38 +0000
3+++ CMakeLists.txt 2014-04-04 16:41:17 +0000
4@@ -36,6 +36,7 @@
5 add_subdirectory(autopilot)
6 add_subdirectory(scope)
7 add_subdirectory(data)
8+add_subdirectory(po)
9
10 # Custom targets for the tests
11 add_custom_target (test
12
13=== modified file 'debian/control'
14--- debian/control 2014-04-02 14:44:39 +0000
15+++ debian/control 2014-04-04 16:41:17 +0000
16@@ -3,7 +3,9 @@
17 Priority: optional
18 Build-Depends: cmake (>= 2.8.10),
19 debhelper (>= 9),
20+ dh-translations,
21 google-mock,
22+ intltool,
23 libglib2.0-dev (>= 2.32),
24 libjsoncpp-dev,
25 libubuntu-download-manager-client-dev,
26
27=== modified file 'debian/rules'
28--- debian/rules 2014-03-24 19:18:13 +0000
29+++ debian/rules 2014-04-04 16:41:17 +0000
30@@ -13,7 +13,7 @@
31 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
32
33 %:
34- dh $@ --buildsystem cmake --fail-missing
35+ dh $@ --buildsystem cmake --with translations --fail-missing
36
37 override_dh_auto_configure:
38 dh_auto_configure -- -DCMAKE_VERBOSE_MAKEFILE=ON
39
40=== added directory 'po'
41=== added file 'po/CMakeLists.txt'
42--- po/CMakeLists.txt 1970-01-01 00:00:00 +0000
43+++ po/CMakeLists.txt 2014-04-04 16:41:17 +0000
44@@ -0,0 +1,36 @@
45+include(FindGettext)
46+find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
47+find_program(INTLTOOL_UPDATE intltool-update)
48+
49+set(GETTEXT_PACKAGE ${PROJECT_NAME})
50+set(POT_FILE ${GETTEXT_PACKAGE}.pot)
51+execute_process(
52+ COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS
53+ OUTPUT_VARIABLE LINGUAS
54+ OUTPUT_STRIP_TRAILING_WHITESPACE
55+)
56+
57+# Creates POTFILES
58+add_custom_target(POTFILES ALL
59+ COMMENT "Generating POTFILES"
60+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/genpotfiles.sh ${CMAKE_SOURCE_DIR}
61+)
62+
63+# Creates the .pot file containing the translations template
64+add_custom_target(${POT_FILE} ALL
65+ COMMENT "Generating translation template"
66+ COMMAND XGETTEXT="${GETTEXT_XGETTEXT_EXECUTABLE}" srcdir="${CMAKE_CURRENT_SOURCE_DIR}" ${INTLTOOL_UPDATE} --gettext-package ${GETTEXT_PACKAGE} --pot
67+ DEPENDS POTFILES
68+)
69+
70+# Builds the binary translations catalog for each language
71+# it finds source translations (*.po) for
72+foreach(LANG ${LINGUAS})
73+ list(APPEND PO_FILES "${LANG}.po")
74+ gettext_process_po_files(${LANG} ALL PO_FILES "${LANG}.po")
75+ set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
76+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
77+ DESTINATION ${INSTALL_DIR}
78+ RENAME ${DOMAIN}.mo
79+ )
80+endforeach(LANG)
81
82=== added file 'po/LINGUAS'
83=== added file 'po/POTFILES.in'
84--- po/POTFILES.in 1970-01-01 00:00:00 +0000
85+++ po/POTFILES.in 2014-04-04 16:41:17 +0000
86@@ -0,0 +1,1 @@
87+scope/click/preview.cpp
88
89=== added file 'po/genpotfiles.sh'
90--- po/genpotfiles.sh 1970-01-01 00:00:00 +0000
91+++ po/genpotfiles.sh 2014-04-04 16:41:17 +0000
92@@ -0,0 +1,6 @@
93+#!/bin/sh
94+
95+sed '/^#/d
96+ s/^[[].*] *//
97+ /^[ ]*$/d' \
98+ "`dirname ${0}`/POTFILES.in" | sed '$!s/$/ \\/' > POTFILES
99
100=== modified file 'scope/click/CMakeLists.txt'
101--- scope/click/CMakeLists.txt 2014-04-01 13:27:09 +0000
102+++ scope/click/CMakeLists.txt 2014-04-04 16:41:17 +0000
103@@ -4,6 +4,11 @@
104 pkg_check_modules(JSON_CPP REQUIRED jsoncpp)
105 pkg_check_modules(LIBURL_DISPATCHER REQUIRED url-dispatcher-1)
106
107+add_definitions(
108+ -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\"
109+ -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_LOCALEDIR}\"
110+)
111+
112 add_library(${SCOPE_LIB_UNVERSIONED} SHARED
113 download-manager.cpp
114 index.cpp
115
116=== added file 'scope/click/click-i18n.h'
117--- scope/click/click-i18n.h 1970-01-01 00:00:00 +0000
118+++ scope/click/click-i18n.h 2014-04-04 16:41:17 +0000
119@@ -0,0 +1,37 @@
120+/*
121+ * Copyright (C) 2014 Canonical Ltd.
122+ *
123+ * This program is free software: you can redistribute it and/or modify it
124+ * under the terms of the GNU General Public License version 3, as published
125+ * by the Free Software Foundation.
126+ *
127+ * This program is distributed in the hope that it will be useful, but
128+ * WITHOUT ANY WARRANTY; without even the implied warranties of
129+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
130+ * PURPOSE. See the GNU General Public License for more details.
131+ *
132+ * You should have received a copy of the GNU General Public License along
133+ * with this program. If not, see <http://www.gnu.org/licenses/>.
134+ *
135+ * In addition, as a special exception, the copyright holders give
136+ * permission to link the code of portions of this program with the
137+ * OpenSSL library under certain conditions as described in each
138+ * individual source file, and distribute linked combinations
139+ * including the two.
140+ * You must obey the GNU General Public License in all respects
141+ * for all of the code used other than OpenSSL. If you modify
142+ * file(s) with this exception, you may extend this exception to your
143+ * version of the file(s), but you are not obligated to do so. If you
144+ * do not wish to do so, delete this exception statement from your
145+ * version. If you delete this exception statement from all source
146+ * files in the program, then also delete it here.
147+ */
148+
149+#ifndef CLICKI18N_H
150+#define CLICKI18N_H
151+
152+#include <libintl.h>
153+
154+#define _(value) dgettext(GETTEXT_PACKAGE, value)
155+
156+#endif
157
158=== modified file 'scope/click/preview.cpp'
159--- scope/click/preview.cpp 2014-04-02 12:01:34 +0000
160+++ scope/click/preview.cpp 2014-04-04 16:41:17 +0000
161@@ -41,6 +41,8 @@
162 #include <iostream>
163 #include <sstream>
164
165+#include "click-i18n.h"
166+
167 namespace click {
168
169 // Preview base class
170@@ -155,18 +157,18 @@
171
172 scopes::PreviewWidgetList Preview::downloadErrorWidgets()
173 {
174- return errorWidgets(scopes::Variant("Download Error"),
175- scopes::Variant("Download or install failed. Please try again."),
176+ return errorWidgets(scopes::Variant(_("Download Error")),
177+ scopes::Variant(_("Download or install failed. Please try again.")),
178 scopes::Variant(click::Preview::Actions::CLOSE_PREVIEW), // TODO see bug LP: #1289434
179- scopes::Variant("Close"));
180+ scopes::Variant(_("Close")));
181 }
182
183 scopes::PreviewWidgetList Preview::loginErrorWidgets()
184 {
185- return errorWidgets(scopes::Variant("Login Error"),
186- scopes::Variant("Please log in to your Ubuntu One account."),
187+ return errorWidgets(scopes::Variant(_("Login Error")),
188+ scopes::Variant(_("Please log in to your Ubuntu One account.")),
189 scopes::Variant(click::Preview::Actions::OPEN_ACCOUNTS),
190- scopes::Variant("Go to Accounts"));
191+ scopes::Variant(_("Go to Accounts")));
192 }
193
194 scopes::PreviewWidgetList Preview::errorWidgets(const scopes::Variant& title,
195@@ -299,12 +301,12 @@
196 builder.add_tuple(
197 {
198 {"id", scopes::Variant(click::Preview::Actions::OPEN_CLICK)},
199- {"label", scopes::Variant("Open")}
200+ {"label", scopes::Variant(_("Open"))}
201 });
202 builder.add_tuple(
203 {
204 {"id", scopes::Variant(click::Preview::Actions::UNINSTALL_CLICK)},
205- {"label", scopes::Variant("Uninstall")}
206+ {"label", scopes::Variant(_("Uninstall"))}
207 });
208 buttons.add_attribute_value("actions", builder.end());
209 widgets.push_back(buttons);
210@@ -358,20 +360,20 @@
211 scopes::PreviewWidgetList widgets;
212
213 scopes::PreviewWidget header("hdr", "header");
214- header.add_attribute_value("title", scopes::Variant("Confirmation"));
215+ header.add_attribute_value("title", scopes::Variant(_("Confirmation")));
216 header.add_attribute_value("subtitle",
217- scopes::Variant("Uninstalling this app will delete all the related information. Are you sure you want to uninstall?")); // TODO: wording needs review. see bug LP: #1234211
218+ scopes::Variant(_("Uninstalling this app will delete all the related information. Are you sure you want to uninstall?"))); // TODO: wording needs review. see bug LP: #1234211
219 widgets.push_back(header);
220
221 scopes::PreviewWidget buttons("buttons", "actions");
222 scopes::VariantBuilder builder;
223 builder.add_tuple({
224 {"id", scopes::Variant(click::Preview::Actions::CLOSE_PREVIEW)}, // TODO: see bug LP: #1289434
225- {"label", scopes::Variant("Not anymore")}
226+ {"label", scopes::Variant(_("Not anymore"))}
227 });
228 builder.add_tuple({
229 {"id", scopes::Variant(click::Preview::Actions::CONFIRM_UNINSTALL)},
230- {"label", scopes::Variant("Yes Uninstall")}
231+ {"label", scopes::Variant(_("Yes Uninstall"))}
232 });
233 buttons.add_attribute_value("actions", builder.end());
234 widgets.push_back(buttons);
235@@ -410,7 +412,7 @@
236 builder.add_tuple(
237 {
238 {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)},
239- {"label", scopes::Variant("Install")},
240+ {"label", scopes::Variant(_("Install"))},
241 {"download_url", scopes::Variant(details.download_url)}
242 });
243 buttons.add_attribute_value("actions", builder.end());
244
245=== modified file 'scope/click/query.cpp'
246--- scope/click/query.cpp 2014-04-03 13:08:47 +0000
247+++ scope/click/query.cpp 2014-04-04 16:41:17 +0000
248@@ -50,6 +50,8 @@
249 #include<set>
250 #include<sstream>
251
252+#include "click-i18n.h"
253+
254 namespace
255 {
256
257@@ -136,7 +138,7 @@
258 replyProxy(replyProxy),
259 installedApplications(installedApplications),
260 renderer(categoryTemplate),
261- category(replyProxy->register_category("appstore", "Available", "", renderer)),
262+ category(replyProxy->register_category("appstore", _("Available"), "", renderer)),
263 queryUrl(queryUri) {
264 }
265
266@@ -246,7 +248,7 @@
267 std::string categoryTemplate)
268 {
269 scopes::CategoryRenderer rdr(categoryTemplate);
270- auto cat = replyProxy->register_category("local", "My apps", "", rdr);
271+ auto cat = replyProxy->register_category("local", _("My apps"), "", rdr);
272
273 // cat might be null when the underlying query got cancelled.
274 if (!cat)
275
276=== modified file 'scope/click/scope.cpp'
277--- scope/click/scope.cpp 2014-03-21 04:31:34 +0000
278+++ scope/click/scope.cpp 2014-04-04 16:41:17 +0000
279@@ -39,6 +39,8 @@
280 #include <QSharedPointer>
281 #include <url-dispatcher.h>
282
283+#include "click-i18n.h"
284+
285 namespace
286 {
287 click::Interface& clickInterfaceInstance()
288@@ -82,6 +84,10 @@
289
290 int click::Scope::start(std::string const&, scopes::RegistryProxy const&)
291 {
292+ setlocale(LC_ALL, "");
293+ bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR);
294+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
295+
296 return VERSION;
297 }
298

Subscribers

People subscribed via source and target branches

to all changes: