Merge lp:~michael-sheldon/ubuntu-download-manager/translation-support into lp:ubuntu-download-manager

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 372
Merged at revision: 371
Proposed branch: lp:~michael-sheldon/ubuntu-download-manager/translation-support
Merge into: lp:ubuntu-download-manager
Diff against target: 422 lines (+194/-11)
13 files modified
CMakeLists.txt (+10/-0)
debian/control (+1/-0)
debian/rules (+4/-1)
po/CMakeLists.txt (+28/-0)
po/ubuntu-download-manager.pot (+57/-0)
src/common/priv/CMakeLists.txt (+4/-2)
src/common/priv/ubuntu/transfers/i18n.cpp (+39/-0)
src/common/priv/ubuntu/transfers/i18n.h (+34/-0)
src/downloads/daemon/main.cpp (+3/-0)
src/downloads/priv/ubuntu/downloads/file_download.cpp (+5/-4)
src/downloads/priv/ubuntu/downloads/group_download.cpp (+3/-2)
src/uploads/daemon/main.cpp (+3/-0)
src/uploads/priv/ubuntu/uploads/file_upload.cpp (+3/-2)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-download-manager/translation-support
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+304495@code.launchpad.net

Commit message

Make user visible strings translatable

Description of the change

Make user visible strings translatable

To post a comment you must log in.
372. By Michael Sheldon

Add missing i18n files

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:372
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-download-manager-ci/13/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1380
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/315
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1380
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1239
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1239
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1239
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1235/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1235
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1235/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-ubuntu-download-manager-ci/13/rebuild

review: Approve (continuous-integration)

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 2015-11-24 16:13:24 +0000
3+++ CMakeLists.txt 2016-08-31 13:30:31 +0000
4@@ -3,6 +3,10 @@
5 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -pthread")
7
8+# for dh_translations to extract the domain
9+# (regarding syntax consistency, see http://pad.lv/1181187)
10+set (GETTEXT_PACKAGE "ubuntu-download-manager")
11+add_definitions(-DI18N_DOMAIN="${GETTEXT_PACKAGE}")
12
13 # Standard install paths
14 include(GNUInstallDirs)
15@@ -37,6 +41,11 @@
16 find_package(Gtest REQUIRED)
17 include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR})
18
19+file(GLOB_RECURSE I18N_CPP_SRC_FILES
20+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
21+ src/**.cpp)
22+list(SORT I18N_CPP_SRC_FILES)
23+
24 # Instruct CMake to run moc automatically when needed.
25 set(CMAKE_AUTOMOC ON)
26
27@@ -72,3 +81,4 @@
28 add_subdirectory(src)
29 add_subdirectory(tests)
30 add_subdirectory(docs)
31+add_subdirectory(po)
32
33=== modified file 'debian/control'
34--- debian/control 2016-08-01 14:19:55 +0000
35+++ debian/control 2016-08-31 13:30:31 +0000
36@@ -4,6 +4,7 @@
37 Build-Depends: cmake,
38 debhelper (>= 9),
39 dh-apparmor,
40+ dh-translations,
41 doxygen,
42 dbus-test-runner,
43 google-mock,
44
45=== modified file 'debian/rules'
46--- debian/rules 2016-06-16 10:18:22 +0000
47+++ debian/rules 2016-08-31 13:30:31 +0000
48@@ -41,8 +41,11 @@
49 dh_install --fail-missing
50
51 %:
52- dh $@ --parallel
53+ dh $@ --parallel --with translations
54
55 override_dh_installdeb:
56 dh_apparmor --profile-name=usr.lib.ubuntu-download-manager.udm-extractor -pubuntu-download-manager
57 dh_installdeb
58+
59+override_dh_translations:
60+ make -C po ubuntu-download-manager.pot
61
62=== added directory 'po'
63=== added file 'po/CMakeLists.txt'
64--- po/CMakeLists.txt 1970-01-01 00:00:00 +0000
65+++ po/CMakeLists.txt 2016-08-31 13:30:31 +0000
66@@ -0,0 +1,28 @@
67+project(ubuntu-download-manager-translations)
68+
69+include(FindGettext)
70+find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
71+
72+set(DOMAIN ${GETTEXT_PACKAGE})
73+set(POT_FILE ${DOMAIN}.pot)
74+file(GLOB PO_FILES *.po)
75+
76+add_custom_target(${POT_FILE}
77+ COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE}
78+ -D ${CMAKE_SOURCE_DIR}
79+ --from-code=UTF-8
80+ --c++ --qt --add-comments=TRANSLATORS
81+ --keyword=_
82+ -j
83+ --package-name=ubuntu-download-manager
84+ --copyright-holder='Canonical Ltd.'
85+ ${I18N_CPP_SRC_FILES})
86+
87+foreach(PO_FILE ${PO_FILES})
88+ get_filename_component(LANG ${PO_FILE} NAME_WE)
89+ gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
90+ set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
91+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
92+ DESTINATION ${INSTALL_DIR}
93+ RENAME ${DOMAIN}.mo)
94+endforeach(PO_FILE)
95
96=== added file 'po/ubuntu-download-manager.pot'
97--- po/ubuntu-download-manager.pot 1970-01-01 00:00:00 +0000
98+++ po/ubuntu-download-manager.pot 2016-08-31 13:30:31 +0000
99@@ -0,0 +1,57 @@
100+# SOME DESCRIPTIVE TITLE.
101+# Copyright (C) YEAR Canonical Ltd.
102+# This file is distributed under the same license as the ubuntu-download-manager package.
103+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
104+#
105+#, fuzzy
106+msgid ""
107+msgstr ""
108+"Project-Id-Version: ubuntu-download-manager\n"
109+"Report-Msgid-Bugs-To: \n"
110+"POT-Creation-Date: 2016-08-31 12:57+0100\n"
111+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
112+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
113+"Language-Team: LANGUAGE <LL@li.org>\n"
114+"Language: \n"
115+"MIME-Version: 1.0\n"
116+"Content-Type: text/plain; charset=CHARSET\n"
117+"Content-Transfer-Encoding: 8bit\n"
118+
119+#: src/downloads/priv/ubuntu/downloads/file_download.cpp:139
120+msgid "Network error "
121+msgstr ""
122+
123+#: src/downloads/priv/ubuntu/downloads/file_download.cpp:210
124+#: src/downloads/priv/ubuntu/downloads/group_download.cpp:123
125+#, qt-format
126+msgid "Invalid hash algorithm: '%1'"
127+msgstr ""
128+
129+#: src/downloads/priv/ubuntu/downloads/file_download.cpp:863
130+#, qt-format
131+msgid "Invalid URL: '%1'"
132+msgstr ""
133+
134+#: src/downloads/priv/ubuntu/downloads/file_download.cpp:873
135+#, qt-format
136+msgid "Downloads that are set to be deflated cannot have a hash: '%1'"
137+msgstr ""
138+
139+#: src/downloads/priv/ubuntu/downloads/file_download.cpp:964
140+#, qt-format
141+msgid "File already exists at: '%2'"
142+msgstr ""
143+
144+#: src/downloads/priv/ubuntu/downloads/group_download.cpp:139
145+msgid "Duplicated local path passed: "
146+msgstr ""
147+
148+#: src/uploads/priv/ubuntu/uploads/file_upload.cpp:160
149+#, qt-format
150+msgid "Path is not absolute: '%1'"
151+msgstr ""
152+
153+#: src/uploads/priv/ubuntu/uploads/file_upload.cpp:166
154+#, qt-format
155+msgid "Path does not exist: '%1'"
156+msgstr ""
157
158=== modified file 'src/common/priv/CMakeLists.txt'
159--- src/common/priv/CMakeLists.txt 2014-11-24 15:28:20 +0000
160+++ src/common/priv/CMakeLists.txt 2016-08-31 13:30:31 +0000
161@@ -3,13 +3,14 @@
162 set(SOURCES
163 ubuntu/transfers/base_daemon.cpp
164 ubuntu/transfers/base_manager.cpp
165+ ubuntu/transfers/i18n.cpp
166 ubuntu/transfers/queue.cpp
167 ubuntu/transfers/transfer.cpp
168 ubuntu/transfers/system/apn_proxy.cpp
169 ubuntu/transfers/system/apn_request_factory.cpp
170 ubuntu/transfers/system/apparmor.cpp
171 ubuntu/transfers/system/application.cpp
172- ubuntu/transfers/system/cryptographic_hash.cpp
173+ ubuntu/transfers/system/cryptographic_hash.cpp
174 ubuntu/transfers/system/dbus_proxy.cpp
175 ubuntu/transfers/system/dbus_proxy_factory.cpp
176 ubuntu/transfers/system/file_manager.cpp
177@@ -29,6 +30,7 @@
178 ubuntu/transfers/adaptor_factory.h
179 ubuntu/transfers/base_daemon.h
180 ubuntu/transfers/base_manager.h
181+ ubuntu/transfers/i18n.h
182 ubuntu/transfers/manager_factory.h
183 ubuntu/transfers/queue.h
184 ubuntu/transfers/transfer.h
185@@ -36,7 +38,7 @@
186 ubuntu/transfers/system/apn_request_factory.h
187 ubuntu/transfers/system/apparmor.h
188 ubuntu/transfers/system/application.h
189- ubuntu/transfers/system/cryptographic_hash.h
190+ ubuntu/transfers/system/cryptographic_hash.h
191 ubuntu/transfers/system/dbus_proxy.h
192 ubuntu/transfers/system/dbus_proxy_factory.h
193 ubuntu/transfers/system/file_manager.h
194
195=== added file 'src/common/priv/ubuntu/transfers/i18n.cpp'
196--- src/common/priv/ubuntu/transfers/i18n.cpp 1970-01-01 00:00:00 +0000
197+++ src/common/priv/ubuntu/transfers/i18n.cpp 2016-08-31 13:30:31 +0000
198@@ -0,0 +1,39 @@
199+/*
200+ * Copyright 2016 Canonical Ltd.
201+ *
202+ * This program is free software: you can redistribute it and/or modify
203+ * it under the terms of the GNU Lesser General Public License version 3 as
204+ * published by the Free Software Foundation.
205+ *
206+ * This program is distributed in the hope that it will be useful,
207+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
208+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209+ * GNU Lesser General Public License for more details.
210+ *
211+ * You should have received a copy of the GNU Lesser General Public License
212+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
213+ */
214+
215+#define NO_TR_OVERRIDE
216+#include "i18n.h"
217+
218+#include <libintl.h>
219+
220+namespace Ubuntu {
221+
222+namespace Transfers {
223+
224+void initTr(const char *domain, const char *localeDir)
225+{
226+ bindtextdomain(domain, localeDir);
227+ textdomain(domain);
228+}
229+
230+QString _(const char *text, const char *domain)
231+{
232+ return QString::fromUtf8(dgettext(domain, text));
233+}
234+
235+}
236+
237+}
238
239=== added file 'src/common/priv/ubuntu/transfers/i18n.h'
240--- src/common/priv/ubuntu/transfers/i18n.h 1970-01-01 00:00:00 +0000
241+++ src/common/priv/ubuntu/transfers/i18n.h 2016-08-31 13:30:31 +0000
242@@ -0,0 +1,34 @@
243+/*
244+ * Copyright 2016 Canonical Ltd.
245+ *
246+ * This program is free software: you can redistribute it and/or modify
247+ * it under the terms of the GNU Lesser General Public License version 3 as
248+ * published by the Free Software Foundation.
249+ *
250+ * This program is distributed in the hope that it will be useful,
251+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
252+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
253+ * GNU Lesser General Public License for more details.
254+ *
255+ * You should have received a copy of the GNU Lesser General Public License
256+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
257+ */
258+
259+#ifndef I18N_H
260+#define I18N_H
261+
262+#include <QString>
263+
264+namespace Ubuntu {
265+
266+namespace Transfers {
267+
268+void initTr(const char *domain, const char *localeDir);
269+QString _(const char *text, const char *domain = 0);
270+
271+}
272+
273+}
274+
275+#endif // I18N_H
276+
277
278=== modified file 'src/downloads/daemon/main.cpp'
279--- src/downloads/daemon/main.cpp 2014-02-25 11:35:57 +0000
280+++ src/downloads/daemon/main.cpp 2016-08-31 13:30:31 +0000
281@@ -19,6 +19,7 @@
282 #include <QTimer>
283 #include <QCoreApplication>
284 #include <ubuntu/downloads/daemon.h>
285+#include <ubuntu/transfers/i18n.h>
286
287 using namespace Ubuntu::DownloadManager::Daemon;
288
289@@ -29,5 +30,7 @@
290 // use a singleShot timer so that we start after exec so that exit works
291 QTimer::singleShot(0, daemon, SLOT(start()));
292
293+ Ubuntu::Transfers::initTr(I18N_DOMAIN, NULL);
294+
295 return a.exec();
296 }
297
298=== modified file 'src/downloads/priv/ubuntu/downloads/file_download.cpp'
299--- src/downloads/priv/ubuntu/downloads/file_download.cpp 2016-04-08 14:29:03 +0000
300+++ src/downloads/priv/ubuntu/downloads/file_download.cpp 2016-08-31 13:30:31 +0000
301@@ -32,6 +32,7 @@
302 #include <QStringList>
303 #include <QSslError>
304
305+#include <ubuntu/transfers/i18n.h>
306 #include <ubuntu/transfers/metadata.h>
307 #include <ubuntu/transfers/system/dbus_connection.h>
308 #include <ubuntu/transfers/system/hash_algorithm.h>
309@@ -207,7 +208,7 @@
310 // check that the algorithm is correct if the hash is not empty
311 if (!_hash.isEmpty() && !HashAlgorithm::isValidAlgo(algo)) {
312 setIsValid(false);
313- setLastError(QString("Invalid hash algorithm: '%1'").arg(algo));
314+ setLastError(QString(_("Invalid hash algorithm: '%1'")).arg(algo));
315 }
316 }
317
318@@ -860,7 +861,7 @@
319 // ensure that the download is valid
320 if (!_url.isValid()) {
321 setIsValid(false);
322- setLastError(QString("Invalid URL: '%1'").arg(_url.toString()));
323+ setLastError(QString(_("Invalid URL: '%1'")).arg(_url.toString()));
324 }
325
326 // ensure that if we are going to deflate the download that the hash is set
327@@ -870,7 +871,7 @@
328 && _metadata[Metadata::DEFLATE_KEY].toBool()) {
329 setIsValid(false);
330 setLastError(QString(
331- "Downloads that are set to be deflated cannot have a hash: '%1'").arg(
332+ _("Downloads that are set to be deflated cannot have a hash: '%1'")).arg(
333 _hash));
334 }
335 }
336@@ -961,7 +962,7 @@
337 // raise an error
338 if (QFile::exists(_filePath)) {
339 setIsValid(false);
340- setLastError(QString("File already exists at: '%1'").arg(
341+ setLastError(QString(_("File already exists at: '%2'")).arg(
342 _filePath));
343 }
344 } else {
345
346=== modified file 'src/downloads/priv/ubuntu/downloads/group_download.cpp'
347--- src/downloads/priv/ubuntu/downloads/group_download.cpp 2015-11-13 14:40:50 +0000
348+++ src/downloads/priv/ubuntu/downloads/group_download.cpp 2016-08-31 13:30:31 +0000
349@@ -19,6 +19,7 @@
350 #include <QDir>
351 #include <QFileInfo>
352 #include <glog/logging.h>
353+#include <ubuntu/transfers/i18n.h>
354 #include <ubuntu/transfers/metadata.h>
355 #include <ubuntu/transfers/system/hash_algorithm.h>
356 #include "ubuntu/transfers/system/logger.h"
357@@ -120,7 +121,7 @@
358 } else {
359 if (!HashAlgorithm::isValidAlgo(algo)) {
360 setIsValid(false);
361- setLastError(QString("Invalid hash algorithm: '%1'").arg(algo));
362+ setLastError(QString(_("Invalid hash algorithm: '%1'")).arg(algo));
363 break;
364 }
365
366@@ -136,7 +137,7 @@
367 QString localFilePath = singleDownload->filePath();
368 if (localPaths.contains(localFilePath)) {
369 setIsValid(false);
370- setLastError("Duplicated local path passed: " + localFilePath);
371+ setLastError(_("Duplicated local path passed: ") + localFilePath);
372 break;
373 } else {
374 localPaths.append(localFilePath);
375
376=== modified file 'src/uploads/daemon/main.cpp'
377--- src/uploads/daemon/main.cpp 2014-02-28 10:42:43 +0000
378+++ src/uploads/daemon/main.cpp 2016-08-31 13:30:31 +0000
379@@ -19,6 +19,7 @@
380 #include <QTimer>
381 #include <QCoreApplication>
382 #include <ubuntu/uploads/daemon.h>
383+#include <ubuntu/transfers/i18n.h>
384
385 using namespace Ubuntu::UploadManager::Daemon;
386
387@@ -29,5 +30,7 @@
388 // use a singleShot timer so that we start after exec so that exit works
389 QTimer::singleShot(0, daemon, SLOT(start()));
390
391+ Ubuntu::Transfers::initTr(I18N_DOMAIN, NULL);
392+
393 return a.exec();
394 }
395
396=== modified file 'src/uploads/priv/ubuntu/uploads/file_upload.cpp'
397--- src/uploads/priv/ubuntu/uploads/file_upload.cpp 2014-07-21 11:22:38 +0000
398+++ src/uploads/priv/ubuntu/uploads/file_upload.cpp 2016-08-31 13:30:31 +0000
399@@ -18,6 +18,7 @@
400
401 #include <QDir>
402 #include <QFileInfo>
403+#include <ubuntu/transfers/i18n.h>
404 #include <ubuntu/transfers/system/logger.h>
405 #include <ubuntu/transfers/system/filename_mutex.h>
406
407@@ -157,13 +158,13 @@
408 if (!info.isAbsolute()) {
409 UP_LOG(INFO) << "Path is not absolute: " << filePath;
410 setIsValid(false);
411- setLastError(QString("Path is not absolute: '%1'").arg(filePath));
412+ setLastError(QString(_("Path is not absolute: '%1'")).arg(filePath));
413 }
414
415 if (isValid() && !info.exists()) {
416 UP_LOG(INFO) << "Path does not exist: " << filePath;
417 setIsValid(false);
418- setLastError(QString("Path does not exist: '%1'").arg(filePath));
419+ setLastError(QString(_("Path does not exist: '%1'")).arg(filePath));
420 }
421
422 if (isValid()) {

Subscribers

People subscribed via source and target branches