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
1=== modified file 'src/formatter-desktop.cpp'
2--- src/formatter-desktop.cpp 2014-01-31 00:33:14 +0000
3+++ src/formatter-desktop.cpp 2014-03-28 00:38:55 +0000
4@@ -38,11 +38,6 @@
5
6 if (date_string && time_string)
7 {
8- /* TRANSLATORS: This is a format string passed to strftime to
9- * combine the date and the time. The value of "%s\u2003%s"
10- * will result in a string like this in US English 12-hour time:
11- * 'Fri Jul 16 11:50 AM'. The space in between date and time is
12- * a Unicode en space (E28082 in UTF-8 hex). */
13 str = date_string;
14 str += "\u2003";
15 str += time_string;
16@@ -134,26 +129,52 @@
17 const char * fmt;
18
19 if (show_day && show_date && show_year)
20- /* TRANSLATORS: a strftime(3) format showing the weekday, date, and year */
21+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
22+ That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
23+ This format string shows the abbreviated weekday, day, abbreviated month, and year.
24+ en_US example: "%a %b %e %Y" --> "Sat Oct 31 2020"
25+ en_GB example: "%a %e %b %Y" --> "Sat 31 Oct 2020"
26+ zh_CN example(?): "%Y年%m月%d日 周%a" --> "2020年10月31日 周六" */
27 fmt = T_("%a %b %e %Y");
28+
29 else if (show_day && show_date)
30- /* TRANSLATORS: a strftime(3) format showing the weekday and date */
31+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
32+ That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
33+ This format string shows the abbreviated weekday, day, and abbreviated month.
34+ en_US example: "%a %b %e" --> "Sat Oct 31"
35+ en_GB example: "%a %e %b" --> "Sat 31 Oct"
36+ zh_CN example(?): "%m月%d日 周%a" --> "03月27日 周六" */
37 fmt = T_("%a %b %e");
38- else if (show_day && show_year)
39- /* TRANSLATORS: a strftime(3) format showing the weekday and year. */
40- fmt = T_("%a %Y");
41+
42 else if (show_day)
43- /* TRANSLATORS: a strftime(3) format showing the weekday. */
44+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
45+ That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
46+ This format string shows the abbreviated weekday.
47+ zh_CN example(?): "周%a" --> "周六" */
48 fmt = T_("%a");
49+
50 else if (show_date && show_year)
51- /* TRANSLATORS: a strftime(3) format showing the date and year */
52+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
53+ That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
54+ This format string shows the day, abbreviated month, and year.
55+ en_US example: "%b %e %Y" --> "Oct 31 2020"
56+ en_GB example: "%e %b %Y" --> "31 Oct 2020"
57+ zh_CN example(?): "%Y年%m月%d日" --> "2020年10月31日" */
58 fmt = T_("%b %e %Y");
59+
60 else if (show_date)
61- /* TRANSLATORS: a strftime(3) format showing the date */
62+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
63+ That will fix bug #1001595 for your locale and make the date/time in the upper-right corner of your screen look beautiful :)
64+ This format string shows the abbreviated month and day.
65+ en_US example: "%b %e" --> "Mar 27"
66+ en_GB example: "%e %b" --> "27 Mar"
67+ zh_CN example(?): "%m月%d日" --> "03月27日" */
68 fmt = T_("%b %e");
69+
70 else if (show_year)
71- /* TRANSLATORS: a strftime(3) format showing the year */
72+ /* This strftime(3) format string shows the year. */
73 fmt = T_("%Y");
74+
75 else
76 fmt = nullptr;
77
78
79=== modified file 'src/menu.cpp'
80--- src/menu.cpp 2014-03-24 16:18:12 +0000
81+++ src/menu.cpp 2014-03-28 00:38:55 +0000
82@@ -247,7 +247,11 @@
83 else
84 action_name = nullptr;
85
86- // add a menuitem that shows the current date
87+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
88+ Format string for the day on the first menuitem in the datetime indicator.
89+ This format string gives the full weekday, date, month, and year.
90+ en_US example: "%A, %B %e %Y" --> Saturday, October 31 2020"
91+ en_GB example: "%A, %e %B %Y" --> Saturday, 31 October 2020" */
92 auto label = m_state->clock->localtime().format(_("%A, %e %B %Y"));
93 auto item = g_menu_item_new (label.c_str(), nullptr);
94 auto v = get_serialized_calendar_icon();
95
96=== modified file 'src/snap.cpp'
97--- src/snap.cpp 2014-03-21 05:22:55 +0000
98+++ src/snap.cpp 2014-03-28 00:38:55 +0000
99@@ -244,7 +244,9 @@
100 {
101 notify_notification_set_hint_string(nn, "x-canonical-snap-decisions", "true");
102 notify_notification_set_hint_string(nn, "x-canonical-private-button-tint", "true");
103+ /* text for the alarm popup dialog's button to show the active alarm */
104 notify_notification_add_action(nn, "show", _("Show"), on_snap_show, data, nullptr);
105+ /* text for the alarm popup dialog's button to shut up the alarm */
106 notify_notification_add_action(nn, "dismiss", _("Dismiss"), on_snap_dismiss, data, nullptr);
107 g_signal_connect(G_OBJECT(nn), "closed", G_CALLBACK(on_snap_closed), data);
108 }
109
110=== modified file 'src/utils.c'
111--- src/utils.c 2014-03-14 16:48:06 +0000
112+++ src/utils.c 2014-03-28 00:38:55 +0000
113@@ -270,30 +270,101 @@
114 {
115 switch (prox)
116 {
117- case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("Today")); break;
118- case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow")); break;
119- case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%A")); break;
120- case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b")); break;
121+ case DATE_PROXIMITY_TODAY:
122+ g_string_assign (ret, T_("Today"));
123+ break;
124+
125+ case DATE_PROXIMITY_TOMORROW:
126+ g_string_assign (ret, T_("Tomorrow"));
127+ break;
128+
129+ case DATE_PROXIMITY_WEEK:
130+ /* This is a strftime(3) format string indicating the unabbreviated weekday. */
131+ g_string_assign (ret, T_("%A"));
132+ break;
133+
134+ case DATE_PROXIMITY_FAR:
135+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
136+ This format string is used for showing full-day events that are over a week away.
137+ en_US example: "%a %b %d" --> "Sat Oct 31"
138+ en_GB example: "%a %d %b" --> "Sat 31 Oct"
139+ zh_CN example(?): "%m月%d日 周%a" --> "10月31日 周六" */
140+ g_string_assign (ret, T_("%a %d %b"));
141+ break;
142 }
143 }
144 else if (is_locale_12h())
145 {
146 switch (prox)
147 {
148- case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("%l:%M %p")); break;
149- case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow\u2003%l:%M %p")); break;
150- case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%a\u2003%l:%M %p")); break;
151- case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b\u2003%l:%M %p")); break;
152+ case DATE_PROXIMITY_TODAY:
153+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
154+ This format string is used for showing, on a 12-hour clock, events/appointments that happen today.
155+ en_US example: "%l:%M %p" --> "1:00 PM" */
156+ g_string_assign (ret, T_("%l:%M %p"));
157+ break;
158+
159+ case DATE_PROXIMITY_TOMORROW:
160+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
161+ This format string is used for showing, on a 12-hour clock, events/appointments that happen tomorrow.
162+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
163+ en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 1:00 PM" */
164+ g_string_assign (ret, T_("Tomorrow\u2003%l:%M %p"));
165+ break;
166+
167+ case DATE_PROXIMITY_WEEK:
168+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
169+ This format string is used for showing, on a 12-hour clock, events/appointments that happen this week.
170+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
171+ en_US example: "Tomorrow\u2003%l:%M %p" --> "Fri 1:00 PM" */
172+ g_string_assign (ret, T_("%a\u2003%l:%M %p"));
173+ break;
174+
175+ case DATE_PROXIMITY_FAR:
176+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
177+ This format string is used for showing, on a 12-hour clock, events/appointments that happen over a week from now.
178+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
179+ en_US example: "%a %d %b\u2003%l:%M %p" --> "Fri Oct 31 1:00 PM"
180+ en_GB example: "%a %b %d\u2003%l:%M %p" --> "Fri 31 Oct 1:00 PM" */
181+ g_string_assign (ret, T_("%a %d %b\u2003%l:%M %p"));
182+ break;
183 }
184 }
185 else
186 {
187 switch (prox)
188 {
189- case DATE_PROXIMITY_TODAY: g_string_assign (ret, T_("%H:%M")); break;
190- case DATE_PROXIMITY_TOMORROW: g_string_assign (ret, T_("Tomorrow\u2003%H:%M")); break;
191- case DATE_PROXIMITY_WEEK: g_string_assign (ret, T_("%a\u2003%H:%M")); break;
192- case DATE_PROXIMITY_FAR: g_string_assign (ret, T_("%a %d %b\u2003%H:%M")); break;
193+ case DATE_PROXIMITY_TODAY:
194+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
195+ This format string is used for showing, on a 24-hour clock, events/appointments that happen today.
196+ en_US example: "%H:%M" --> "13:00" */
197+ g_string_assign (ret, T_("%H:%M"));
198+ break;
199+
200+ case DATE_PROXIMITY_TOMORROW:
201+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
202+ This format string is used for showing, on a 24-hour clock, events/appointments that happen tomorrow.
203+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
204+ en_US example: "Tomorrow\u2003%l:%M %p" --> "Tomorrow 13:00" */
205+ g_string_assign (ret, T_("Tomorrow\u2003%H:%M"));
206+ break;
207+
208+ case DATE_PROXIMITY_WEEK:
209+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
210+ This format string is used for showing, on a 24-hour clock, events/appointments that happen this week.
211+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
212+ en_US example: "%a\u2003%H:%M" --> "Fri 13:00" */
213+ g_string_assign (ret, T_("%a\u2003%H:%M"));
214+ break;
215+
216+ case DATE_PROXIMITY_FAR:
217+ /* Translators, please edit/rearrange these strftime(3) tokens to suit your locale!
218+ This format string is used for showing, on a 24-hour clock, events/appointments that happen over a week from now.
219+ (\u2003 is a unicode em space which is slightly wider than a normal space.)
220+ en_US example: "%a %d %b\u2003%H:%M" --> "Fri Oct 31 13:00"
221+ en_GB example: "%a %b %d\u2003%H:%M" --> "Fri 31 Oct 13:00" */
222+ g_string_assign (ret, T_("%a %d %b\u2003%H:%M"));
223+ break;
224 }
225 }
226

Subscribers

People subscribed via source and target branches