Merge lp:~nikwen/ubuntu-calendar-app/fix-standalone-month-name-i18n into lp:ubuntu-calendar-app

Proposed by Niklas Wenzel
Status: Needs review
Proposed branch: lp:~nikwen/ubuntu-calendar-app/fix-standalone-month-name-i18n
Merge into: lp:ubuntu-calendar-app
Diff against target: 330 lines (+61/-67)
4 files modified
DayView.qml (+3/-5)
MonthView.qml (+3/-5)
WeekView.qml (+9/-10)
po/com.ubuntu.calendar.pot (+46/-47)
To merge this branch: bzr merge lp:~nikwen/ubuntu-calendar-app/fix-standalone-month-name-i18n
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Nekhelesh Ramananthan Needs Fixing
David Planella Needs Fixing
Kunal Parmar Pending
Review via email: mp+279509@code.launchpad.net

Commit message

Fix bad month translations for some languages, e.g. Polish

Description of the change

Fix bad month translations for some languages, e.g. Polish

See the related bug report for more information on why this change is necessary. ;)

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
736. By Niklas Wenzel

Remove id attribute that I used during testing

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kunal Parmar (pkunal-parmar) wrote :

Thanks :), this changes seems fine to me, but need to test is once and then approve it

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

Why do you need to call qsTr()? IIRC, it should work with i18n.tr() only already.

qsTr(i18n.tr("%1 %2")).arg(Qt.locale().standaloneMonthName(currentMonth.getMonth(), Locale.LongFormat)).arg(currentMonth.getFullYear())

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

Sorry, to be more specific:

- Qt.locale() should choose the right locale for you already for the standaloneMonthName, without needing qsTr()
- Does currentMonth.getFullYear() not need to be localized as well?

review: Needs Information
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thank you, Kunal and David, for looking into this.

@David, to clear this up a bit:

qsTr() is responsible only for the format string here. i18n.tr() delivers the translated format string while qsTr() in combination with the arg() calls then goes ahead and replaces %1 and %2 with the arguments, i.e. the month and the year. That said, qsTr() does not do any translation job and is only needed for the format string story. I couldn't find anything in the i18n documentation to replace the qsTr() and arg() calls here. [1]
Regarding the year: Qt.locale() does not provide any way to localize the year. [2] Hence, I don't think we need to do anything, especially considering that we are talking about a number.

[1] https://developer.ubuntu.com/api/apps/qml/sdk-15.04.1/Ubuntu.Components.i18n/
[2] http://doc.qt.io/qt-5/qml-qtqml-locale.html

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Any update on this? Kunal, have you given it a try yet?

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

I've just double-checked this again, and I can confirm that the qsTr() call is not required. i18n.tr() (gettext) already takes care of the format string, it is not necessary to process it again with qsTr().

This can easily be tested with a simple QML app that includes the following string:

i18n.tr("%1 %2").arg(Qt.locale().standaloneMonthName(10, Locale.LongFormat)).arg("2011")

review: Needs Fixing
737. By Niklas Wenzel

Remove qsTr() calls

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

So I just learned something new. Thanks, David! :)

(By the way, would it be possible to add an example for that to https://developer.ubuntu.com/api/apps/qml/sdk-15.04.1/Ubuntu.Components.i18n/ ?)

Now I just have to sort out the merge conflicts.

738. By Niklas Wenzel

Merge trunk

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Fixed the merge conflicts. Would you mind looking into it again, please? :)

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Looking at the Jenkins logs, I don't think the test failures are related to the changes here. (Please correct me if I'm wrong, though!) Any idea what was happening?

Revision history for this message
Niklas Wenzel (nikwen) wrote :

No ideas?

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

@nikwen, Hi there, we're looking to release calendar v0.5 with OTA-10. I would like to get this bug fix into trunk before that. Can we work on getting this done?

I have two questions,

1. why at all do we need i18n.tr() calls? Can we just do "%1 %2".arg().arg() which then substitutes the month and year accordingly? Or is this for RTL language support where the order may need to be changed?

2. calendar app trunk has gone through a huge code change. Please merge trunk and push again pls.

review: Needs Fixing
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Hey Nekhelesh,

I'm sorry for being a bit late.

The reason why I put the i18n.tr() calls in there is because there might be languages in which it is "2016 April" instead of "April 2016". I'm not sure about whether there are any such languages, but if we are already fixing translation issues, I'd prefer to make it as flexible as possible. Furthermore, in my opinion the i18n.tr() calls don't hurt anyone if no such languages exist.

I'll merge trunk now. :)

739. By Niklas Wenzel

Merge trunk

740. By Niklas Wenzel

Also fix bug in a new place where it has been introduced

741. By Niklas Wenzel

Readd newlines where accidently removed

742. By Niklas Wenzel

Empty commit to make LP rebuild the diff

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Finished merging. Thank you for your patience, Nekhelesh! :)

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

Thanks Niklas, and good work everyone!

On Wed, Apr 6, 2016 at 10:38 PM, Niklas Wenzel <email address hidden>
wrote:

> Finished merging. Thank you for your patience, Nekhelesh! :)
> --
>
> https://code.launchpad.net/~nikwen/ubuntu-calendar-app/fix-standalone-month-name-i18n/+merge/279509
> You are reviewing the proposed merge of
> lp:~nikwen/ubuntu-calendar-app/fix-standalone-month-name-i18n into
> lp:ubuntu-calendar-app.
>

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Nekhelesh, would you mind having a look at this again? :)

Unmerged revisions

742. By Niklas Wenzel

Empty commit to make LP rebuild the diff

741. By Niklas Wenzel

Readd newlines where accidently removed

740. By Niklas Wenzel

Also fix bug in a new place where it has been introduced

739. By Niklas Wenzel

Merge trunk

738. By Niklas Wenzel

Merge trunk

737. By Niklas Wenzel

Remove qsTr() calls

736. By Niklas Wenzel

Remove id attribute that I used during testing

735. By Niklas Wenzel

Fix bad month translations for some languages, e.g. Polish

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DayView.qml'
2--- DayView.qml 2016-03-17 01:51:25 +0000
3+++ DayView.qml 2016-04-06 20:33:43 +0000
4@@ -116,11 +116,9 @@
5 currentDate.getDate())
6 return ("%1 %2").arg(lunarDate .IMonthCn).arg(lunarDate.gzYear)
7 } else {
8- // TRANSLATORS: this is a time formatting string,
9- // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
10- // It's used in the header of the month and week views
11- var monthName = currentDate.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy"))
12- return monthName[0].toUpperCase() + monthName.substr(1, monthName.length - 1)
13+ // TRANSLATORS: This string is used in the headers of the month, week and day views.
14+ // %1 is going to be replaced by the month name, %2 by the year.
15+ return i18n.tr("%1 %2").arg(Qt.locale().standaloneMonthName(currentDate.getMonth(), Locale.LongFormat)).arg(currentDate.getFullYear())
16 }
17 }
18 }
19
20=== modified file 'MonthView.qml'
21--- MonthView.qml 2016-03-17 01:51:25 +0000
22+++ MonthView.qml 2016-04-06 20:33:43 +0000
23@@ -72,11 +72,9 @@
24 var lunarDate = Lunar.calendar.solar2lunar(year, month + 1, day)
25 return i18n.tr("%1 %2").arg(lunarDate .IMonthCn).arg(lunarDate.gzYear)
26 } else {
27- // TRANSLATORS: this is a time formatting string,
28- // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
29- // It's used in the header of the month and week views
30- var monthName = currentDate.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy"))
31- return monthName[0].toUpperCase() + monthName.substr(1, monthName.length - 1)
32+ // TRANSLATORS: This string is used in the headers of the month, week and day views.
33+ // %1 is going to be replaced by the month name, %2 by the year.
34+ return i18n.tr("%1 %2").arg(Qt.locale().standaloneMonthName(currentDate.getMonth(), Locale.LongFormat)).arg(currentDate.getFullYear())
35 }
36 }
37 flickable: null
38
39=== modified file 'WeekView.qml'
40--- WeekView.qml 2016-03-17 01:51:25 +0000
41+++ WeekView.qml 2016-04-06 20:33:43 +0000
42@@ -130,19 +130,18 @@
43 currentDate.getDate())
44 return i18n.tr("%1 %2").arg(lunarDate .IMonthCn).arg(lunarDate.gzYear)
45 } else {
46- // TRANSLATORS: this is a time formatting string,
47- // see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
48- // It's used in the header of the month and week views
49 var currentLastDayOfWeek = currentFirstDayOfWeek.addDays(7)
50 if (currentLastDayOfWeek.getMonth() !== currentFirstDayOfWeek.getMonth()) {
51- var firstMonthName = currentFirstDayOfWeek.toLocaleString(Qt.locale(),i18n.tr("MMM"))
52- var lastMonthName = currentLastDayOfWeek.toLocaleString(Qt.locale(),i18n.tr("MMM"))
53- return (firstMonthName[0].toUpperCase() + firstMonthName.substr(1, 2) + "/" +
54- lastMonthName[0].toUpperCase() + lastMonthName.substr(1, 2) + " " +
55- currentLastDayOfWeek.getFullYear())
56+ // TRANSLATORS: This string is used in the header of the week view when the current week contains days from two different months.
57+ // %1 is going to be replaced by the first month's name, %2 by the second month's name and %3 by the year.
58+ return i18n.tr("%1/%2 %3")
59+ .arg(Qt.locale().standaloneMonthName(currentFirstDayOfWeek.getMonth(), Locale.ShortFormat))
60+ .arg(Qt.locale().standaloneMonthName(currentLastDayOfWeek.getMonth(), Locale.ShortFormat))
61+ .arg(currentDate.getFullYear())
62 } else {
63- var monthName = currentDate.toLocaleString(Qt.locale(),i18n.tr("MMMM yyyy"))
64- return monthName[0].toUpperCase() + monthName.substr(1, monthName.length - 1)
65+ // TRANSLATORS: This string is used in the headers of the month, week and day views.
66+ // %1 is going to be replaced by the month name, %2 by the year.
67+ return i18n.tr("%1 %2").arg(Qt.locale().standaloneMonthName(currentDate.getMonth(), Locale.LongFormat)).arg(currentDate.getFullYear())
68 }
69 }
70 }
71
72=== modified file 'po/com.ubuntu.calendar.pot'
73--- po/com.ubuntu.calendar.pot 2016-03-23 03:59:15 +0000
74+++ po/com.ubuntu.calendar.pot 2016-04-06 20:33:43 +0000
75@@ -8,7 +8,7 @@
76 msgstr ""
77 "Project-Id-Version: \n"
78 "Report-Msgid-Bugs-To: \n"
79-"POT-Creation-Date: 2016-03-23 00:58-0300\n"
80+"POT-Creation-Date: 2016-04-06 22:28+0200\n"
81 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
82 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
83 "Language-Team: LANGUAGE <LL@li.org>\n"
84@@ -18,7 +18,7 @@
85 "Content-Transfer-Encoding: 8bit\n"
86 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
87
88-#: ../AgendaView.qml:50 ../calendar.qml:344 ../calendar.qml:576
89+#: ../AgendaView.qml:50 ../calendar.qml:348 ../calendar.qml:580
90 msgid "Agenda"
91 msgstr ""
92
93@@ -104,7 +104,7 @@
94 msgstr ""
95
96 #: ../ColorPickerDialog.qml:55 ../DeleteConfirmationDialog.qml:60
97-#: ../EditEventConfirmationDialog.qml:53 ../NewEvent.qml:341
98+#: ../EditEventConfirmationDialog.qml:53 ../NewEvent.qml:328
99 msgid "Cancel"
100 msgstr ""
101
102@@ -120,11 +120,12 @@
103 msgid "Today"
104 msgstr ""
105
106-#. TRANSLATORS: this is a time formatting string,
107-#. see http://qt-project.org/doc/qt-5/qml-qtqml-date.html#details for valid expressions.
108-#. It's used in the header of the month and week views
109-#: ../DayView.qml:122 ../MonthView.qml:78 ../WeekView.qml:144
110-msgid "MMMM yyyy"
111+#. TRANSLATORS: This string is used in the headers of the month, week and day views.
112+#. %1 is going to be replaced by the month name, %2 by the year.
113+#: ../DayView.qml:120 ../MonthView.qml:73 ../MonthView.qml:77
114+#: ../WeekView.qml:130 ../WeekView.qml:143
115+#, qt-format
116+msgid "%1 %2"
117 msgstr ""
118
119 #: ../DeleteConfirmationDialog.qml:31
120@@ -154,11 +155,11 @@
121 msgid "Delete this"
122 msgstr ""
123
124-#: ../DeleteConfirmationDialog.qml:51 ../NewEvent.qml:348
125+#: ../DeleteConfirmationDialog.qml:51 ../NewEvent.qml:335
126 msgid "Delete"
127 msgstr ""
128
129-#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:336
130+#: ../EditEventConfirmationDialog.qml:29 ../NewEvent.qml:323
131 msgid "Edit Event"
132 msgstr ""
133
134@@ -182,12 +183,12 @@
135
136 #. TRANSLATORS: the first argument (%1) refers to a start time for an event,
137 #. while the second one (%2) refers to the end time
138-#: ../EventBubble.qml:100
139+#: ../EventBubble.qml:134
140 #, qt-format
141 msgid "%1 - %2"
142 msgstr ""
143
144-#: ../EventDetails.qml:37 ../NewEvent.qml:484
145+#: ../EventDetails.qml:37 ../NewEvent.qml:493
146 msgid "Event Details"
147 msgstr ""
148
149@@ -195,32 +196,32 @@
150 msgid "Edit"
151 msgstr ""
152
153-#: ../EventDetails.qml:164 ../TimeLineHeader.qml:66
154+#: ../EventDetails.qml:167 ../TimeLineHeader.qml:66
155 msgid "All Day"
156 msgstr ""
157
158-#: ../EventDetails.qml:336 ../NewEvent.qml:549
159+#: ../EventDetails.qml:339 ../NewEvent.qml:559
160 #: com.ubuntu.calendar_calendar.desktop.in.in.h:1
161 msgid "Calendar"
162 msgstr ""
163
164-#: ../EventDetails.qml:369
165+#: ../EventDetails.qml:372
166 msgid "Not Attending"
167 msgstr ""
168
169-#: ../EventDetails.qml:373
170+#: ../EventDetails.qml:376
171 msgid "Attending"
172 msgstr ""
173
174-#: ../EventDetails.qml:377
175+#: ../EventDetails.qml:380
176 msgid "No Reply"
177 msgstr ""
178
179-#: ../EventDetails.qml:400 ../NewEvent.qml:515
180+#: ../EventDetails.qml:403 ../NewEvent.qml:525
181 msgid "Description"
182 msgstr ""
183
184-#: ../EventDetails.qml:418 ../EventReminder.qml:36 ../NewEvent.qml:711
185+#: ../EventDetails.qml:421 ../NewEvent.qml:718 ../NewEvent.qml:757
186 msgid "Reminder"
187 msgstr ""
188
189@@ -228,7 +229,7 @@
190 #. and it is shown as the header of the page to choose repetition
191 #. and as the header of the list item that shows the repetition
192 #. summary in the page that displays the event details
193-#: ../EventRepetition.qml:40 ../EventRepetition.qml:153
194+#: ../EventRepetition.qml:40 ../EventRepetition.qml:152
195 msgid "Repeat"
196 msgstr ""
197
198@@ -236,18 +237,18 @@
199 msgid "Repeats On:"
200 msgstr ""
201
202-#: ../EventRepetition.qml:217
203+#: ../EventRepetition.qml:218
204 msgid "Recurring event ends"
205 msgstr ""
206
207 #. TRANSLATORS: this refers to how often a recurrent event repeats
208 #. and it is shown as the header of the option selector to choose
209 #. its repetition
210-#: ../EventRepetition.qml:240 ../NewEvent.qml:685
211+#: ../EventRepetition.qml:242 ../NewEvent.qml:694
212 msgid "Repeats"
213 msgstr ""
214
215-#: ../EventRepetition.qml:265
216+#: ../EventRepetition.qml:268
217 msgid "Date"
218 msgstr ""
219
220@@ -288,60 +289,55 @@
221
222 #. TRANSLATORS: This is shown in the month view as "Wk" as a title
223 #. to indicate the week numbers. It should be a max of up to 3 characters.
224-#: ../MonthComponent.qml:317
225+#: ../MonthComponent.qml:316
226 msgid "Wk"
227 msgstr ""
228
229-#: ../MonthView.qml:73 ../WeekView.qml:131
230-#, qt-format
231-msgid "%1 %2"
232-msgstr ""
233-
234-#: ../NewEvent.qml:179
235+#: ../NewEvent.qml:182
236 msgid "End time can't be before start time"
237 msgstr ""
238
239-#: ../NewEvent.qml:336 ../NewEventBottomEdge.qml:53
240+#: ../NewEvent.qml:323 ../NewEventBottomEdge.qml:53
241 msgid "New Event"
242 msgstr ""
243
244-#: ../NewEvent.qml:365
245+#: ../NewEvent.qml:352
246 msgid "Save"
247 msgstr ""
248
249-#: ../NewEvent.qml:376
250+#: ../NewEvent.qml:363
251 msgid "Error"
252 msgstr ""
253
254-#: ../NewEvent.qml:378
255+#: ../NewEvent.qml:365
256 msgid "OK"
257 msgstr ""
258
259-#: ../NewEvent.qml:438
260+#: ../NewEvent.qml:427
261 msgid "From"
262 msgstr ""
263
264-#: ../NewEvent.qml:451
265+#: ../NewEvent.qml:443
266 msgid "To"
267 msgstr ""
268
269-#: ../NewEvent.qml:468
270+#: ../NewEvent.qml:470
271 msgid "All day event"
272 msgstr ""
273
274-#: ../NewEvent.qml:497
275+#: ../NewEvent.qml:507
276 msgid "Event Name"
277 msgstr ""
278
279-#: ../NewEvent.qml:534
280+#: ../NewEvent.qml:544
281 msgid "Location"
282 msgstr ""
283
284-#: ../NewEvent.qml:589
285+#: ../NewEvent.qml:600
286 msgid "Guests"
287 msgstr ""
288
289-#: ../NewEvent.qml:598
290+#: ../NewEvent.qml:610
291 msgid "Add Guest"
292 msgstr ""
293
294@@ -450,8 +446,11 @@
295 msgid "W%1"
296 msgstr ""
297
298-#: ../WeekView.qml:138 ../WeekView.qml:139
299-msgid "MMM"
300+#. TRANSLATORS: This string is used in the header of the week view when the current week contains days from two different months.
301+#. %1 is going to be replaced by the first month's name, %2 by the second month's name and %3 by the year.
302+#: ../WeekView.qml:136
303+#, qt-format
304+msgid "%1/%2 %3"
305 msgstr ""
306
307 #: ../YearView.qml:79
308@@ -466,19 +465,19 @@
309 "about them"
310 msgstr ""
311
312-#: ../calendar.qml:312 ../calendar.qml:492
313+#: ../calendar.qml:316 ../calendar.qml:496
314 msgid "Year"
315 msgstr ""
316
317-#: ../calendar.qml:320 ../calendar.qml:513
318+#: ../calendar.qml:324 ../calendar.qml:517
319 msgid "Month"
320 msgstr ""
321
322-#: ../calendar.qml:328 ../calendar.qml:534
323+#: ../calendar.qml:332 ../calendar.qml:538
324 msgid "Week"
325 msgstr ""
326
327-#: ../calendar.qml:336 ../calendar.qml:555
328+#: ../calendar.qml:340 ../calendar.qml:559
329 msgid "Day"
330 msgstr ""
331

Subscribers

People subscribed via source and target branches

to status/vote changes: