Merge lp:~mhr3/unity-scope-scopes/i18n-enablement into lp:unity-scope-scopes

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 39
Merged at revision: 34
Proposed branch: lp:~mhr3/unity-scope-scopes/i18n-enablement
Merge into: lp:unity-scope-scopes
Diff against target: 285 lines (+164/-16)
8 files modified
CMakeLists.txt (+6/-0)
debian/control (+1/-0)
po/CMakeLists.txt (+53/-0)
po/unity-scope-scopes.pot (+52/-0)
src/CMakeLists.txt (+12/-4)
src/i18n.h (+25/-0)
src/scopes-scope.cpp (+8/-5)
src/scopes.ini.in.in (+7/-7)
To merge this branch: bzr merge lp:~mhr3/unity-scope-scopes/i18n-enablement
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
Review via email: mp+217642@code.launchpad.net

Commit message

Add i18n support.

Description of the change

Add i18n support.

To post a comment you must log in.
35. By Michal Hruby

Fix the FIXME

36. By Michal Hruby

Update pot

37. By Michal Hruby

Add missing file

38. By Michal Hruby

Install mo, added missing setlocale call

39. By Michal Hruby

Fix ini install rule

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good. +1

review: Approve

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-04 13:32:17 +0000
3+++ CMakeLists.txt 2014-04-30 10:36:28 +0000
4@@ -8,6 +8,11 @@
5 "libunity-scopes >= 0.4.0"
6 )
7
8+find_program(XGETTEXT_BIN xgettext)
9+find_program(MSGFMT_BIN msgfmt)
10+find_program(INTLTOOL_EXTRACT_BIN intltool-extract)
11+find_program(INTLTOOL_MERGE_BIN intltool-merge)
12+
13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wmissing-declarations -pedantic -std=c++11")
14
15 set(DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data")
16@@ -25,6 +30,7 @@
17 )
18 include_directories(${CMAKE_CURRENT_BINARY_DIR})
19
20+add_subdirectory("po")
21 add_subdirectory("src")
22
23 enable_testing()
24
25=== modified file 'debian/control'
26--- debian/control 2014-03-04 13:32:17 +0000
27+++ debian/control 2014-04-30 10:36:28 +0000
28@@ -4,6 +4,7 @@
29 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
30 Build-Depends: cmake (>= 2.8),
31 debhelper (>= 9),
32+ intltool,
33 libunity-scopes-dev (>= 0.4.0),
34 pkg-config,
35 Standards-Version: 3.9.5
36
37=== added directory 'po'
38=== added file 'po/CMakeLists.txt'
39--- po/CMakeLists.txt 1970-01-01 00:00:00 +0000
40+++ po/CMakeLists.txt 2014-04-30 10:36:28 +0000
41@@ -0,0 +1,53 @@
42+file(GLOB CPPFILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
43+ "${CMAKE_SOURCE_DIR}/src/*.cpp")
44+file(GLOB INIFILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
45+ "${CMAKE_SOURCE_DIR}/src/*.ini.in.in")
46+
47+foreach(inifile ${INIFILES})
48+ get_filename_component(fname ${inifile} NAME)
49+ set(iniheaderfile "${CMAKE_CURRENT_SOURCE_DIR}/tmp/${fname}.h")
50+ list(APPEND GENERATED_HEADERS ${iniheaderfile})
51+ add_custom_command(OUTPUT ${iniheaderfile}
52+ COMMAND ${INTLTOOL_EXTRACT_BIN} --type=gettext/ini --local ${inifile}
53+ DEPENDS ${inifile}
54+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
55+ )
56+endforeach()
57+
58+add_custom_target(pot-ini
59+ DEPENDS ${GENERATED_HEADERS}
60+)
61+
62+add_custom_target(pot
63+ COMMAND ${XGETTEXT_BIN} -o ${GETTEXT_PACKAGE}.pot
64+ --copyright=\"Canonical Ltd.\"
65+ --package-name ${GETTEXT_PACKAGE}
66+ --c++ --add-comments=TRANSLATORS
67+ --keyword=_ --keyword=N_ --from-code=UTF-8
68+ ${CPPFILES} "tmp/*.h"
69+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
70+ DEPENDS pot-ini
71+)
72+
73+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale)
74+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale DESTINATION share)
75+
76+file(GLOB pofiles *.po)
77+foreach(f ${pofiles})
78+ get_filename_component(pofile ${f} NAME_WE)
79+ set(languages "${pofile};${languages}")
80+endforeach()
81+
82+MESSAGE("${languages}")
83+
84+foreach(i ${languages})
85+ add_custom_command(OUTPUT ${i}.mo
86+ COMMAND ${MSGFMT_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/${i}.po -o ${CMAKE_CURRENT_BINARY_DIR}/${i}.mo
87+ DEPENDS ${i}.po
88+ )
89+ add_custom_target(${i}gen ALL DEPENDS ${i}.mo)
90+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${i}.mo
91+ DESTINATION share/locale/${i}/LC_MESSAGES
92+ RENAME ${GETTEXT_PACKAGE}.mo)
93+endforeach()
94+
95
96=== added file 'po/unity-scope-scopes.pot'
97--- po/unity-scope-scopes.pot 1970-01-01 00:00:00 +0000
98+++ po/unity-scope-scopes.pot 2014-04-30 10:36:28 +0000
99@@ -0,0 +1,52 @@
100+# SOME DESCRIPTIVE TITLE.
101+# Copyright (C) YEAR Canonical Ltd.
102+# This file is distributed under the same license as the PACKAGE package.
103+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
104+#
105+#, fuzzy
106+msgid ""
107+msgstr ""
108+"Project-Id-Version: unity-scope-scopes\n"
109+"Report-Msgid-Bugs-To: \n"
110+"POT-Creation-Date: 2014-04-29 17:44+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/scopes-scope.cpp:206
120+msgid "Featured"
121+msgstr ""
122+
123+#: ../src/scopes-scope.cpp:208
124+msgid "Entertainment"
125+msgstr ""
126+
127+#: ../src/scopes-scope.cpp:210
128+msgid "Other"
129+msgstr ""
130+
131+#: ../src/scopes-scope.cpp:239 tmp/scopes.ini.in.in.h:1
132+msgid "Scopes"
133+msgstr ""
134+
135+#: ../src/scopes-scope.cpp:431
136+msgid "Description"
137+msgstr ""
138+
139+#: ../src/scopes-scope.cpp:438
140+msgid "Search"
141+msgstr ""
142+
143+#: tmp/scopes.ini.in.in.h:2
144+msgid ""
145+"This is an Ubuntu search plugin that displays and allows searching available "
146+"scopes."
147+msgstr ""
148+
149+#: tmp/scopes.ini.in.in.h:3
150+msgid "Search for scopes"
151+msgstr ""
152
153=== modified file 'src/CMakeLists.txt'
154--- src/CMakeLists.txt 2014-03-06 13:09:11 +0000
155+++ src/CMakeLists.txt 2014-04-30 10:36:28 +0000
156@@ -12,7 +12,15 @@
157 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/unity-scopes/scopes"
158 )
159
160-install(
161- FILES scopes.ini
162- DESTINATION "${CMAKE_INSTALL_LIBDIR}/unity-scopes/scopes"
163-)
164+set(SCOPE_CONFIG_FILES scopes.ini)
165+
166+foreach(configfile ${SCOPE_CONFIG_FILES})
167+ configure_file(${configfile}.in.in ${configfile}.in)
168+ get_filename_component(basename ${configfile} NAME_WE)
169+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${configfile}"
170+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/unity-scopes/${basename}")
171+ add_custom_command(OUTPUT ${configfile} COMMAND ${INTLTOOL_MERGE_BIN} -d ${CMAKE_CURRENT_SOURCE_DIR}/../po ${configfile}.in ${configfile})
172+endforeach()
173+
174+add_custom_target(ini-i18n ALL DEPENDS ${SCOPE_CONFIG_FILES})
175+
176
177=== added file 'src/i18n.h'
178--- src/i18n.h 1970-01-01 00:00:00 +0000
179+++ src/i18n.h 2014-04-30 10:36:28 +0000
180@@ -0,0 +1,25 @@
181+/*
182+ * Copyright (C) 2014 Canonical Ltd.
183+ *
184+ * This program is free software: you can redistribute it and/or modify it
185+ * under the terms of the GNU General Public License version 3, as published
186+ * by the Free Software Foundation.
187+ *
188+ * This program is distributed in the hope that it will be useful, but
189+ * WITHOUT ANY WARRANTY; without even the implied warranties of
190+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
191+ * PURPOSE. See the GNU General Public License for more details.
192+ *
193+ * You should have received a copy of the GNU General Public License along
194+ * with this program. If not, see <http://www.gnu.org/licenses/>.
195+ */
196+
197+#ifndef SCOPE_I18N_H
198+#define SCOPE_I18N_H
199+
200+#include <libintl.h>
201+#include <config.h>
202+
203+#define _(value) dgettext(GETTEXT_PACKAGE, value)
204+
205+#endif
206
207=== modified file 'src/scopes-scope.cpp'
208--- src/scopes-scope.cpp 2014-04-01 13:32:26 +0000
209+++ src/scopes-scope.cpp 2014-04-30 10:36:28 +0000
210@@ -31,6 +31,7 @@
211
212 #include "scopes-scope.h"
213 #include "resultcollector.h"
214+#include "i18n.h"
215
216 using namespace unity::scopes;
217
218@@ -71,6 +72,7 @@
219 )";
220
221 int ScopesScope::start(std::string const&, RegistryProxy const &registry) {
222+ setlocale(LC_ALL, "");
223 this->registry = registry;
224 try {
225 online_scope = registry->get_metadata(ONLINE_SCOPE_ID).proxy();
226@@ -202,11 +204,11 @@
227 CategoryRenderer renderer(SCOPES_CATEGORY_DEFINITION);
228 Category::SCPtr categories[N_CATEGORIES];
229 categories[CAT_FEATURED] = reply->register_category(
230- "popular", "Featured", "", renderer);
231+ "popular", _("Featured"), "", renderer);
232 categories[CAT_ENTERTAINMENT] = reply->register_category(
233- "entertainment", "Entertainment", "", renderer);
234+ "entertainment", _("Entertainment"), "", renderer);
235 categories[CAT_OTHER] = reply->register_category(
236- "scopes", "Other", "", renderer);
237+ "scopes", _("Other"), "", renderer);
238
239 MetadataMap all_scopes = scope.registry->list();
240 std::vector<ScopeMetadata> scopes;
241@@ -235,7 +237,7 @@
242 void ScopesQuery::search_query(SearchReplyProxy const &reply) {
243 CategoryRenderer renderer(SEARCH_CATEGORY_DEFINITION);
244 Category::SCPtr category = reply->register_category(
245- "scopes", "Scopes", "", renderer);
246+ "scopes", _("Scopes"), "", renderer);
247
248 std::string term = lowercase(query.query_string());
249
250@@ -427,13 +429,14 @@
251
252 PreviewWidget description("description", "text");
253 description.add_attribute_mapping("text", "description");
254+ description.add_attribute_value("title", Variant(_("Description")));
255
256 PreviewWidget actions("actions", "actions");
257 {
258 VariantBuilder builder;
259 builder.add_tuple({
260 {"id", Variant("search")},
261- {"label", Variant("Search")}
262+ {"label", Variant(_("Search"))}
263 });
264 actions.add_attribute_value("actions", builder.end());
265 }
266
267=== renamed file 'src/scopes.ini' => 'src/scopes.ini.in.in'
268--- src/scopes.ini 2014-03-05 10:13:09 +0000
269+++ src/scopes.ini.in.in 2014-04-30 10:36:28 +0000
270@@ -1,8 +1,8 @@
271 [ScopeConfig]
272-DisplayName = Scopes
273-Author = Canonical Ltd.
274-Description = This is an Ubuntu search plugin that enables information from available search plugins to be searched and displayed in the Dash underneath the Dash plugins header. If you do not wish to search this content source, you can disable this search plugin.
275-SearchHint = Search for scopes
276-HotKey =
277-Author = Canonical Ltd.
278-Invisible = true
279+_DisplayName=Scopes
280+Author=Canonical Ltd.
281+_Description=This is an Ubuntu search plugin that displays and allows searching available scopes.
282+_SearchHint=Search for scopes
283+HotKey=
284+Author=Canonical Ltd.
285+Invisible=true

Subscribers

People subscribed via source and target branches

to all changes: