Merge lp:~charlesk/indicator-datetime/lp-1001595 into lp:indicator-datetime/14.04

Proposed by Charles Kerr
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 334
Merged at revision: 335
Proposed branch: lp:~charlesk/indicator-datetime/lp-1001595
Merge into: lp:indicator-datetime/14.04
Diff against target: 225 lines (+125/-27)
4 files modified
src/formatter-desktop.cpp (+35/-14)
src/menu.cpp (+5/-1)
src/snap.cpp (+2/-0)
src/utils.c (+83/-12)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1001595
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+213174@code.launchpad.net

Commit message

Improved translator comments for better time/date localization.

Description of the change

When I started looking into bug #100595, I didn't have to research very many languages before realizing there isn't a one-size-fits-all solution that can be addressed in the source code.

For example, the code could check nl_langinfo(D_FMT) to see whether the month or day goes first, and that would solve the MM DD YYYY <--> DD MM YYYY complaints that are part of bug #100595.

However there are all kinds of other issues and combinations, for example en zh_CN the weekday should go after the date, rather than before, and the date format is YMD rather than DMY or MDY. And there are special cases for lots of locales. Some of this can be handled by looking at nl_langinfo(), but since we have explicit combinations of date fields in indicator-datetime, we can't handle them all without a lot of guesswork.

In the end, this is best fixed on a locale-by-locale basis by the translators who actually know how their specific locale should look. However, indicator-datetime's code hasn't made this easy in the past due to sparse comments. I've expanded on them in this patch, showing examples and encouraging translators to rearrange the strftime(3) tokens as needed for their locale.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

looks good, thanks Charles!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/formatter-desktop.cpp'
--- src/formatter-desktop.cpp 2014-01-31 00:33:14 +0000
+++ src/formatter-desktop.cpp 2014-03-28 00:38:55 +0000
@@ -38,11 +38,6 @@
3838
39 if (date_string && time_string)39 if (date_string && time_string)
40 {40 {
41 /* TRANSLATORS: This is a format string passed to strftime to
42 * combine the date and the time. The value of "%s\u2003%s"
43 * will result in a string like this in US English 12-hour time:
44 * 'Fri Jul 16 11:50 AM'. The space in between date and time is
45 * a Unicode en space (E28082 in UTF-8 hex). */
46 str = date_string;41 str = date_string;
47 str += "\u2003";42 str += "\u2003";
48 str += time_string;43 str += time_string;
@@ -134,26 +129,52 @@
134 const char * fmt;129 const char * fmt;
135130
136 if (show_day && show_date && show_year)131 if (show_day && show_date && show_year)
137 /* TRANSLATORS: a strftime(3) format showing the weekday, date, and year */132 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
133 That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
134 This format string shows the abbreviated weekday, day, abbreviated month, and year.
135 en_US example: "%a %b %e %Y" --> "Sat Oct 31 2020"
136 en_GB example: "%a %e %b %Y" --> "Sat 31 Oct 2020"
137 zh_CN example(?): "%Y年%m月%d日 周%a" --> "2020年10月31日 周六" */
138 fmt = T_("%a %b %e %Y");138 fmt = T_("%a %b %e %Y");
139
139 else if (show_day && show_date)140 else if (show_day && show_date)
140 /* TRANSLATORS: a strftime(3) format showing the weekday and date */141 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
142 That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
143 This format string shows the abbreviated weekday, day, and abbreviated month.
144 en_US example: "%a %b %e" --> "Sat Oct 31"
145 en_GB example: "%a %e %b" --> "Sat 31 Oct"
146 zh_CN example(?): "%m月%d日 周%a" --> "03月27日 周六" */
141 fmt = T_("%a %b %e");147 fmt = T_("%a %b %e");
142 else if (show_day && show_year)148
143 /* TRANSLATORS: a strftime(3) format showing the weekday and year. */
144 fmt = T_("%a %Y");
145 else if (show_day)149 else if (show_day)
146 /* TRANSLATORS: a strftime(3) format showing the weekday. */150 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
151 That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
152 This format string shows the abbreviated weekday.
153 zh_CN example(?): "周%a" --> "周六" */
147 fmt = T_("%a");154 fmt = T_("%a");
155
148 else if (show_date && show_year)156 else if (show_date && show_year)
149 /* TRANSLATORS: a strftime(3) format showing the date and year */157 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
158 That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
159 This format string shows the day, abbreviated month, and year.
160 en_US example: "%b %e %Y" --> "Oct 31 2020"
161 en_GB example: "%e %b %Y" --> "31 Oct 2020"
162 zh_CN example(?): "%Y年%m月%d日" --> "2020年10月31日" */
150 fmt = T_("%b %e %Y");163 fmt = T_("%b %e %Y");
164
151 else if (show_date)165 else if (show_date)
152 /* TRANSLATORS: a strftime(3) format showing the date */166 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
167 That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
168 This format string shows the abbreviated month and day.
169 en_US example: "%b %e" --> "Mar 27"
170 en_GB example: "%e %b" --> "27 Mar"
171 zh_CN example(?): "%m月%d日" --> "03月27日" */
153 fmt = T_("%b %e");172 fmt = T_("%b %e");
173
154 else if (show_year)174 else if (show_year)
155 /* TRANSLATORS: a strftime(3) format showing the year */175 /* This strftime(3) format string shows the year. */
156 fmt = T_("%Y");176 fmt = T_("%Y");
177
157 else178 else
158 fmt = nullptr;179 fmt = nullptr;
159180
160181
=== modified file 'src/menu.cpp'
--- src/menu.cpp 2014-03-24 16:18:12 +0000
+++ src/menu.cpp 2014-03-28 00:38:55 +0000
@@ -247,7 +247,11 @@
247 else247 else
248 action_name = nullptr;248 action_name = nullptr;
249249
250 // add a menuitem that shows the current date250 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
251 Format string for the day on the first menuitem in the datetime indicator.
252 This format string gives the full weekday, date, month, and year.
253 en_US example: "%A, %B %e %Y" --> Saturday, October 31 2020"
254 en_GB example: "%A, %e %B %Y" --> Saturday, 31 October 2020" */
251 auto label = m_state->clock->localtime().format(_("%A, %e %B %Y"));255 auto label = m_state->clock->localtime().format(_("%A, %e %B %Y"));
252 auto item = g_menu_item_new (label.c_str(), nullptr);256 auto item = g_menu_item_new (label.c_str(), nullptr);
253 auto v = get_serialized_calendar_icon();257 auto v = get_serialized_calendar_icon();
254258
=== modified file 'src/snap.cpp'
--- src/snap.cpp 2014-03-21 05:22:55 +0000
+++ src/snap.cpp 2014-03-28 00:38:55 +0000
@@ -244,7 +244,9 @@
244 {244 {
245 notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true");245 notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true");
246 notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true");246 notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true");
247 /* text for the alarm popup dialog's button to show the active alarm */
247 notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr);248 notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr);
249 /* text for the alarm popup dialog's button to shut up the alarm */
248 notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr);250 notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr);
249 g_signal_connect(G_OBJECT(nn), "closed", G_CALLBACK(on_snap_closed), data);251 g_signal_connect(G_OBJECT(nn), "closed", G_CALLBACK(on_snap_closed), data);
250 }252 }
251253
=== modified file 'src/utils.c'
--- src/utils.c 2014-03-14 16:48:06 +0000
+++ src/utils.c 2014-03-28 00:38:55 +0000
@@ -270,30 +270,101 @@
270 {270 {
271 switch (prox)271 switch (prox)
272 {272 {
273 case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("Today")); break;273 case DATE_PROXIMITY_TODAY:
274 case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow")); break;274 g_string_assign (ret, T_("Today"));
275 case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%A")); break;275 break;
276 case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b")); break;276
277 case DATE_PROXIMITY_TOMORROW:
278 g_string_assign (ret, T_("Tomorrow"));
279 break;
280
281 case DATE_PROXIMITY_WEEK:
282 /* This is a strftime(3) format string indicating the unabbreviated weekday. */
283 g_string_assign (ret, T_("%A"));
284 break;
285
286 case DATE_PROXIMITY_FAR:
287 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
288 This format string is used for showing full-day events that are over a week away.
289 en_US example: "%a %b %d" --> "Sat Oct 31"
290 en_GB example: "%a %d %b" --> "Sat 31 Oct"
291 zh_CN example(?): "%m月%d日 周%a" --> "10月31日 周六" */
292 g_string_assign (ret, T_("%a %d %b"));
293 break;
277 }294 }
278 }295 }
279 else if (is_locale_12h())296 else if (is_locale_12h())
280 {297 {
281 switch (prox)298 switch (prox)
282 {299 {
283 case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("%l:%M %p")); break;300 case DATE_PROXIMITY_TODAY:
284 case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow\u2003%l:%M %p")); break;301 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
285 case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%a\u2003%l:%M %p")); break;302 This format string is used for showing, on a 12-hour clock, events/appointments that happen today.
286 case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b\u2003%l:%M %p")); break;303 en_US example: "%l:%M %p" --> "1:00 PM" */
304 g_string_assign (ret, T_("%l:%M %p"));
305 break;
306
307 case DATE_PROXIMITY_TOMORROW:
308 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
309 This format string is used for showing, on a 12-hour clock, events/appointments that happen tomorrow.
310 (\u2003 is a unicode em space which is slightly wider than a normal space.)
311 en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 1:00 PM" */
312 g_string_assign (ret, T_("Tomorrow\u2003%l:%M %p"));
313 break;
314
315 case DATE_PROXIMITY_WEEK:
316 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
317 This format string is used for showing, on a 12-hour clock, events/appointments that happen this week.
318 (\u2003 is a unicode em space which is slightly wider than a normal space.)
319 en_US example: "Tomorrow\u2003%l:%M %p" --> "Fri 1:00 PM" */
320 g_string_assign (ret, T_("%a\u2003%l:%M %p"));
321 break;
322
323 case DATE_PROXIMITY_FAR:
324 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
325 This format string is used for showing, on a 12-hour clock, events/appointments that happen over a week from now.
326 (\u2003 is a unicode em space which is slightly wider than a normal space.)
327 en_US example: "%a %d %b\u2003%l:%M %p" --> "Fri Oct 31 1:00 PM"
328 en_GB example: "%a %b %d\u2003%l:%M %p" --> "Fri 31 Oct 1:00 PM" */
329 g_string_assign (ret, T_("%a %d %b\u2003%l:%M %p"));
330 break;
287 }331 }
288 }332 }
289 else333 else
290 {334 {
291 switch (prox)335 switch (prox)
292 {336 {
293 case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("%H:%M")); break;337 case DATE_PROXIMITY_TODAY:
294 case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow\u2003%H:%M")); break;338 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
295 case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%a\u2003%H:%M")); break;339 This format string is used for showing, on a 24-hour clock, events/appointments that happen today.
296 case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b\u2003%H:%M")); break;340 en_US example: "%H:%M" --> "13:00" */
341 g_string_assign (ret, T_("%H:%M"));
342 break;
343
344 case DATE_PROXIMITY_TOMORROW:
345 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
346 This format string is used for showing, on a 24-hour clock, events/appointments that happen tomorrow.
347 (\u2003 is a unicode em space which is slightly wider than a normal space.)
348 en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 13:00" */
349 g_string_assign (ret, T_("Tomorrow\u2003%H:%M"));
350 break;
351
352 case DATE_PROXIMITY_WEEK:
353 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
354 This format string is used for showing, on a 24-hour clock, events/appointments that happen this week.
355 (\u2003 is a unicode em space which is slightly wider than a normal space.)
356 en_US example: "%a\u2003%H:%M" --> "Fri 13:00" */
357 g_string_assign (ret, T_("%a\u2003%H:%M"));
358 break;
359
360 case DATE_PROXIMITY_FAR:
361 /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
362 This format string is used for showing, on a 24-hour clock, events/appointments that happen over a week from now.
363 (\u2003 is a unicode em space which is slightly wider than a normal space.)
364 en_US example: "%a %d %b\u2003%H:%M" --> "Fri Oct 31 13:00"
365 en_GB example: "%a %b %d\u2003%H:%M" --> "Fri 31 Oct 13:00" */
366 g_string_assign (ret, T_("%a %d %b\u2003%H:%M"));
367 break;
297 }368 }
298 }369 }
299370

Subscribers

People subscribed via source and target branches