Merge lp:~martin-borho/ubuntu-weather-app/fix-1324578-optionselectors-xlated into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: David Planella
Approved revision: 265
Merged at revision: 263
Proposed branch: lp:~martin-borho/ubuntu-weather-app/fix-1324578-optionselectors-xlated
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 434 lines (+164/-125)
4 files modified
components/SettingsSheet.qml (+32/-14)
po/com.ubuntu.weather.pot (+125/-105)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+4/-3)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+3/-3)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/fix-1324578-optionselectors-xlated
Reviewer Review Type Date Requested Status
David Planella Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+221532@code.launchpad.net

Commit message

Fill optionselectors in settings sheet dynamically, to achieve label localization, fixes Bug #1324578

Description of the change

Fill optionselectors in settings sheet dynamically, to achieve label localization, fixes Bug #1324578

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

Awesome, thanks Martin! Could you update the .pot file as part of this MP, so that it includes the new strings?

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
263. By Martin Borho

updated the .pot file

Revision history for this message
Martin Borho (martin-borho) wrote :

David, I've updated the .pot file, from within QtCreator. It's ok?

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
264. By Martin Borho

pep8 fixes

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
265. By Martin Borho

pep8 again

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

LGTM, thanks!

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

Oh, I was a bit too quick approving and hadn't noticed the fact that you mentioned that you'd updated the .pot file via Qt Creator.

The .pot update option in Qt Creator is not working too well and should probably be disabled. We should be updating the .pot file using the method described in the README.translations file. I'll set up a branch with a new update to the .pot file.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components/SettingsSheet.qml'
2--- components/SettingsSheet.qml 2014-02-22 15:38:15 +0000
3+++ components/SettingsSheet.qml 2014-06-02 12:59:42 +0000
4@@ -28,6 +28,38 @@
5 contentsHeight: parent.height
6 contentsWidth: parent.width
7
8+ function fillTempSelector() {
9+ with(temperatureUnitsSelectorModel) {
10+ append({ name: "celsiusOption", label: i18n.tr("Celsius")});
11+ append({ name: "fahrenheitOption", label: i18n.tr("Fahrenheit")});
12+ }
13+ temperatureUnitsSelector.selectedIndex = (settings["units"] === "imperial") ? 1 : 0;
14+ }
15+
16+ function fillWindSelector() {
17+ with(windUnitsSelectorModel) {
18+ append({ name: "kmhOption", label: i18n.tr("Kilometers per hour")});
19+ append({ name: "mphOption", label: i18n.tr("Miles per hour")});
20+ }
21+ windUnitsSelector.selectedIndex = (settings["wind_units"] === "mph") ? 1 : 0;
22+ }
23+
24+ function fillPrecipSelector() {
25+ with(precipitationUnitsSelectorModel) {
26+ append({ name: "millimetersOption", label: i18n.tr("Millimeters")});
27+ append({ name: "inchesOption", label: i18n.tr("Inches")});
28+ }
29+ precipitationUnitsSelector.selectedIndex = (settings["precip_units"] === "in") ? 1 : 0;
30+ }
31+
32+ Component.onCompleted: {
33+ fillTempSelector();
34+ fillWindSelector();
35+ fillPrecipSelector();
36+ mainView.shortCutsLimited = true;
37+ Theme.palette.selected.backgroundText = "#656565"
38+ }
39+
40 container: Column {
41 anchors.left: parent.left
42 anchors.right: parent.right
43@@ -42,8 +74,6 @@
44
45 ListModel {
46 id: temperatureUnitsSelectorModel
47- ListElement { name: "celsiusOption"; label: "Celsius"; }
48- ListElement { name: "fahrenheitOption"; label: "Fahrenheit"; }
49 }
50
51 OptionSelector {
52@@ -52,13 +82,10 @@
53 text: i18n.tr("Temperature units")
54 delegate: unitsSelectorDelegate
55 model: temperatureUnitsSelectorModel
56- selectedIndex: (settings["units"] === "imperial") ? 1 : 0;
57 }
58
59 ListModel {
60 id: windUnitsSelectorModel
61- ListElement { name: "kmhOption"; label: "Kilometers per hour" }
62- ListElement { name: "mphOption"; label: "Miles per hour" }
63 }
64
65 OptionSelector {
66@@ -67,13 +94,10 @@
67 text: i18n.tr("Wind speed units")
68 delegate: unitsSelectorDelegate
69 model: windUnitsSelectorModel
70- selectedIndex: (settings["wind_units"] === "mph") ? 1 : 0;
71 }
72
73 ListModel {
74 id: precipitationUnitsSelectorModel
75- ListElement { name: "millimetersOption"; label: "Millimeters" }
76- ListElement { name: "inchesOption"; label: "Inches" }
77 }
78
79 OptionSelector {
80@@ -82,7 +106,6 @@
81 text: i18n.tr("Precipitation units")
82 delegate: unitsSelectorDelegate
83 model: precipitationUnitsSelectorModel
84- selectedIndex: (settings["precip_units"] === "in") ? 1 : 0;
85 // Precipitation units not available at TWC
86 visible: (serviceSelector.selectedIndex !== 0) ? 1 : 0
87 opacity: (serviceSelector.selectedIndex !== 0) ? 1 : 0
88@@ -114,11 +137,6 @@
89 }
90 }
91
92- Component.onCompleted: {
93- mainView.shortCutsLimited = true;
94- Theme.palette.selected.backgroundText = "#656565"
95- }
96-
97 signal cancelSheet()
98 onCancelSheet: {
99 Theme.palette.selected.backgroundText = "#f4f4e8";
100
101=== modified file 'po/com.ubuntu.weather.pot'
102--- po/com.ubuntu.weather.pot 2014-03-12 11:47:05 +0000
103+++ po/com.ubuntu.weather.pot 2014-06-02 12:59:42 +0000
104@@ -1,14 +1,14 @@
105 # SOME DESCRIPTIVE TITLE.
106-# Copyright (C) YEAR Canonical Ltd.
107+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
108 # This file is distributed under the same license as the PACKAGE package.
109 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
110 #
111 #, fuzzy
112 msgid ""
113 msgstr ""
114-"Project-Id-Version: ubuntu-weather-app\n"
115+"Project-Id-Version: PACKAGE VERSION\n"
116 "Report-Msgid-Bugs-To: \n"
117-"POT-Creation-Date: 2014-03-12 06:45-0500\n"
118+"POT-Creation-Date: 2014-06-02 14:21+0200\n"
119 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
120 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
121 "Language-Team: LANGUAGE <LL@li.org>\n"
122@@ -17,11 +17,15 @@
123 "Content-Type: text/plain; charset=CHARSET\n"
124 "Content-Transfer-Encoding: 8bit\n"
125
126-#: com.ubuntu.weather_weather.desktop.in.in:7
127-msgid "Weather"
128-msgstr ""
129-
130-#: components/AddLocationSheet.qml:33 components/LocationManagerSheet.qml:300
131+#: components/LastUpdatedComponent.qml:35
132+msgid "Updated: "
133+msgstr ""
134+
135+#: components/LastUpdatedComponent.qml:39
136+msgid "Today, "
137+msgstr ""
138+
139+#: components/AddLocationSheet.qml:33 components/LocationManagerSheet.qml:301
140 msgid "Add city"
141 msgstr ""
142
143@@ -34,6 +38,109 @@
144 msgid "Enter a city name"
145 msgstr ""
146
147+#: components/LocationTab.qml:183
148+msgid "Forecast"
149+msgstr ""
150+
151+#: components/LocationTab.qml:328
152+msgid ""
153+"No weather data available at the moment, please try to refresh later again!"
154+msgstr ""
155+
156+#: components/LocationTab.qml:344
157+msgid "Refresh"
158+msgstr ""
159+
160+#: components/LocationTab.qml:357
161+msgid "Edit"
162+msgstr ""
163+
164+#: components/LocationTab.qml:369 components/SettingsSheet.qml:27
165+msgid "Settings"
166+msgstr ""
167+
168+#: components/SplashComponent.qml:35
169+msgid "Couldn't load weather data, please try later again!"
170+msgstr ""
171+
172+#: components/LocationManagerSheet.qml:33
173+msgid "Edit locations"
174+msgstr ""
175+
176+#: components/LocationManagerSheet.qml:121
177+msgid "Current location"
178+msgstr ""
179+
180+#: components/LocationManagerSheet.qml:144
181+msgid "Scan for location"
182+msgstr ""
183+
184+#. TRANSLATORS: this is the button to add a location (city) that has been
185+#. detected to be the current position
186+#: components/LocationManagerSheet.qml:209
187+msgid "Add"
188+msgstr ""
189+
190+#: components/LocationManagerSheet.qml:229
191+msgid "World"
192+msgstr ""
193+
194+#: components/LocationManagerSheet.qml:319
195+msgid "Location already added."
196+msgstr ""
197+
198+#: components/LocationManagerSheet.qml:321
199+msgid "OK"
200+msgstr ""
201+
202+#: components/LocationManagerSheet.qml:374
203+msgid "Couldn't specify your current location, please try later again!"
204+msgstr ""
205+
206+#: components/LoadingSpinnerComponent.qml:44
207+msgid "Loading..."
208+msgstr ""
209+
210+#: components/SettingsSheet.qml:33
211+msgid "Celsius"
212+msgstr ""
213+
214+#: components/SettingsSheet.qml:34
215+msgid "Fahrenheit"
216+msgstr ""
217+
218+#: components/SettingsSheet.qml:41
219+msgid "Kilometers per hour"
220+msgstr ""
221+
222+#: components/SettingsSheet.qml:42
223+msgid "Miles per hour"
224+msgstr ""
225+
226+#: components/SettingsSheet.qml:49
227+msgid "Millimeters"
228+msgstr ""
229+
230+#: components/SettingsSheet.qml:50
231+msgid "Inches"
232+msgstr ""
233+
234+#: components/SettingsSheet.qml:82
235+msgid "Temperature units"
236+msgstr ""
237+
238+#: components/SettingsSheet.qml:94
239+msgid "Wind speed units"
240+msgstr ""
241+
242+#: components/SettingsSheet.qml:106
243+msgid "Precipitation units"
244+msgstr ""
245+
246+#: components/SettingsSheet.qml:133
247+msgid "Weather Service"
248+msgstr ""
249+
250 #: components/CurrentWeather.qml:62 components/CurrentWeatherDetail.qml:32
251 msgid "Chance of Snow"
252 msgstr ""
253@@ -62,6 +169,16 @@
254 msgid "Extreme"
255 msgstr ""
256
257+#. TRANSLATORS: this refers to the High (max) temperature forecasted for a day
258+#: components/WeatherTemperatureComponent.qml:113
259+msgid "H:"
260+msgstr ""
261+
262+#. TRANSLATORS: this refers to the Low (min) temperature forecasted for a day
263+#: components/WeatherTemperatureComponent.qml:133
264+msgid "L:"
265+msgstr ""
266+
267 #: components/CurrentWeatherDetail.qml:69
268 msgid "Humidity"
269 msgstr ""
270@@ -90,93 +207,6 @@
271 msgid "Precipitation"
272 msgstr ""
273
274-#: components/LastUpdatedComponent.qml:35
275-msgid "Updated: "
276-msgstr ""
277-
278-#: components/LastUpdatedComponent.qml:39
279-msgid "Today, "
280-msgstr ""
281-
282-#: components/LoadingSpinnerComponent.qml:44
283-msgid "Loading..."
284-msgstr ""
285-
286-#: components/LocationManagerSheet.qml:33
287-msgid "Edit locations"
288-msgstr ""
289-
290-#: components/LocationManagerSheet.qml:120
291-msgid "Current location"
292-msgstr ""
293-
294-#: components/LocationManagerSheet.qml:143
295-msgid "Scan for location"
296-msgstr ""
297-
298-#. TRANSLATORS: this is the button to add a location (city) that has been
299-#. detected to be the current position
300-#: components/LocationManagerSheet.qml:208
301-msgid "Add"
302-msgstr ""
303-
304-#: components/LocationManagerSheet.qml:228
305-msgid "World"
306-msgstr ""
307-
308-#: components/LocationManagerSheet.qml:318
309-msgid "Location already added."
310-msgstr ""
311-
312-#: components/LocationManagerSheet.qml:320
313-msgid "OK"
314-msgstr ""
315-
316-#: components/LocationManagerSheet.qml:370
317-msgid "Couldn't specify your current location, please try later again!"
318-msgstr ""
319-
320-#: components/LocationTab.qml:182
321-msgid "Forecast"
322-msgstr ""
323-
324-#: components/LocationTab.qml:351
325-msgid ""
326-"No weather data available at the moment, please try to refresh later again!"
327-msgstr ""
328-
329-#: components/LocationTab.qml:367
330-msgid "Refresh"
331-msgstr ""
332-
333-#: components/LocationTab.qml:380
334-msgid "Edit"
335-msgstr ""
336-
337-#: components/LocationTab.qml:392 components/SettingsSheet.qml:27
338-msgid "Settings"
339-msgstr ""
340-
341-#: components/SettingsSheet.qml:52
342-msgid "Temperature units"
343-msgstr ""
344-
345-#: components/SettingsSheet.qml:67
346-msgid "Wind speed units"
347-msgstr ""
348-
349-#: components/SettingsSheet.qml:82
350-msgid "Precipitation units"
351-msgstr ""
352-
353-#: components/SettingsSheet.qml:110
354-msgid "Weather Service"
355-msgstr ""
356-
357-#: components/SplashComponent.qml:35
358-msgid "Couldn't load weather data, please try later again!"
359-msgstr ""
360-
361 #: components/TabFooter.qml:98
362 msgid "10 days forecast"
363 msgstr ""
364@@ -184,13 +214,3 @@
365 #: components/TabFooter.qml:120
366 msgid "Hourly forecast"
367 msgstr ""
368-
369-#. TRANSLATORS: this refers to the High (max) temperature forecasted for a day
370-#: components/WeatherTemperatureComponent.qml:233
371-msgid "H:"
372-msgstr ""
373-
374-#. TRANSLATORS: this refers to the Low (min) temperature forecasted for a day
375-#: components/WeatherTemperatureComponent.qml:253
376-msgid "L:"
377-msgstr ""
378
379=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
380--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-05-19 16:05:56 +0000
381+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-06-02 12:59:42 +0000
382@@ -134,7 +134,8 @@
383 db_file = "34e1e542f2f083ff18f537b07a380071.sqlite"
384 db_path = os.path.join(db_dir, db_file)
385
386- json_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..', 'files'))
387+ json_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
388+ '..', 'files'))
389
390 def _execute_sql(self, statement):
391 conn = sqlite3.connect(self.db_path)
392@@ -178,7 +179,7 @@
393
394 def get_locations_data(self):
395 result = []
396- json_files = [self.json_path+'/1.json', self.json_path+'/2.json']
397+ json_files = [self.json_path + '/1.json', self.json_path + '/2.json']
398 for path in json_files:
399 with open(path) as fh:
400 json_str = fh.read()
401@@ -194,7 +195,7 @@
402 for loc_data in locations:
403 db_exec = "INSERT INTO Locations(date, data) VALUES('{}', '{}')"
404 cursor.execute(db_exec.format(
405- int(time.time()*1000), loc_data))
406+ int(time.time() * 1000), loc_data))
407 conn.commit()
408 conn.close()
409
410
411=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
412--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-05-19 16:05:56 +0000
413+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-06-02 12:59:42 +0000
414@@ -72,9 +72,9 @@
415 x, y, w, h = first_location.globalRect
416 tx = x + (w / 8)
417 ty = y + (h / 2)
418- self.pointing_device.drag(tx, ty, tx + w/4*3, ty)
419+ self.pointing_device.drag(tx, ty, tx + w / 4 * 3, ty)
420 self.assertThat(self._get_number_of_locations,
421- Eventually(Equals(number_of_locations-1)))
422+ Eventually(Equals(number_of_locations - 1)))
423
424 def _get_number_of_locations(self):
425 qqlw = self.app.wait_select_single("ComposerSheet").wait_select_single(
426@@ -274,7 +274,7 @@
427 # back to locations, only one is left
428 self.main_view.wait_for_activity_to_finish()
429 tabObjects = lambda: len(self.main_view.select_many('LocationTab'))
430- self.assertThat(tabObjects, Eventually(Equals(tabsSumStart-1)))
431+ self.assertThat(tabObjects, Eventually(Equals(tabsSumStart - 1)))
432
433 def test_cancel_remove_location(self):
434 """Cancels removing of location"""

Subscribers

People subscribed via source and target branches