After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 392747 - [indic] [cal] Abbreviated day names are in english for month view, while they appear in indic lang chars when seen in print-preview/actual-print.
[indic] [cal] Abbreviated day names are in english for month view, while they...
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Calendar
2.12.x
Other Linux
: Normal normal
: ---
Assigned To: Matthew Barnes
Evolution QA team
: 523032 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-01-04 14:02 UTC by makuchaku (Mayank)
Modified: 2013-09-13 00:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
Print preview (48.20 KB, image/png)
2007-01-04 14:03 UTC, makuchaku (Mayank)
  Details
Month view (90.69 KB, image/png)
2007-01-04 14:04 UTC, makuchaku (Mayank)
  Details
Buggy screenshot (101.78 KB, image/png)
2007-01-05 15:12 UTC, makuchaku (Mayank)
  Details
Patch for the bug. (5.76 KB, patch)
2007-01-05 15:14 UTC, makuchaku (Mayank)
reviewed Details | Review
Fixed screenshot. (109.80 KB, image/png)
2007-01-05 15:15 UTC, makuchaku (Mayank)
  Details
proposed evo patch (9.38 KB, patch)
2007-10-19 13:56 UTC, Milan Crha
none Details | Review
Fix weekday name problem. (3.66 KB, patch)
2007-11-20 05:37 UTC, huzheng
needs-work Details | Review
Revised patch (8.11 KB, patch)
2007-11-28 20:08 UTC, Matthew Barnes
committed Details | Review
Supplemental patch (15.76 KB, patch)
2007-12-03 22:56 UTC, Matthew Barnes
committed Details | Review

Description makuchaku (Mayank) 2007-01-04 14:02:45 UTC
Description of problem:
Abbreviated day names are in english for month view, while they appear in indic lang chars when seen in print-preview/actual-print.

Version-Release number of selected component (if applicable):
evolution-2.9.4-4.fc7

How reproducible:
Everytime during printing

Steps to Reproduce:
1. Open Evoluton with pa_IN.UTF-8 evolution
2. Goto Calender-Month View, have a look at date navigator in bottom-left corner. It has day names in english for indic languages.
3. Print and see the printed calendar
  
Actual results:
In month view, date navigator's days names are not translated

Expected results:
In month view, date navigator's days names should be translated or picked up from the current locale data.
Comment 1 makuchaku (Mayank) 2007-01-04 14:03:59 UTC
Created attachment 79379 [details]
Print preview
Comment 2 makuchaku (Mayank) 2007-01-04 14:04:34 UTC
Created attachment 79380 [details]
Month view

Notice the circled day names.
Comment 3 makuchaku (Mayank) 2007-01-04 14:06:36 UTC
ECalendarItem is the actual navigatable widget in ECalendar.

And this bug originates from this code in e_calendar_item_init in e-calendar-item.c

---------------------
	/* Translators: These are the first characters of each day of the
	   week, 'M' for 'Monday', 'T' for Tuesday etc. */
	calitem->days = _("MTWTFSS");
---------------------

The _("MTWTFSS") is set in the UI using 

-------
for (day = 0; day < 7; day++) {
		layout_set_day_text (calitem, layout, day_index);
-------

and layout_set_day_text simply picks up one char at the day_index value & add it
to pango layout.

One possible fix is that the code can be modified to pick up values of
abbriviated day names from glibc.

I would not recommend translating  _("MTWTFSS") as in almost all indic langs, day's 1st char would make no sense. Moreover, if this string is picked up from locale data, it would be always correct... as compared to be depending upon translator's translation.
Comment 4 makuchaku (Mayank) 2007-01-05 15:12:23 UTC
Created attachment 79446 [details]
Buggy screenshot

Following translation was used in this screenshot

#. Translators: These are the first characters of each day of the
#. week, 'M' for 'Monday', 'T' for Tuesday etc.
#: ../widgets/misc/e-calendar-item.c:416
msgid "MTWTFSS"
msgstr "सोमंबुगुशुशर"
Comment 5 makuchaku (Mayank) 2007-01-05 15:12:59 UTC
Weekday-picker also seems to have this problem...

#. The first letter of each day of the week starting with Sunday
#: ../calendar/gui/weekday-picker.c:319
msgid "SMTWTFS"
msgstr "SMTWTFS"
Comment 6 makuchaku (Mayank) 2007-01-05 15:14:55 UTC
Created attachment 79447 [details] [review]
Patch for the bug.

This patch makes sure that both e-calendar-item and weekday-picker.c use same translations. I have used contexts in strings for aiding the translation. This patch will generate new untranslated strings.
Comment 7 makuchaku (Mayank) 2007-01-05 15:15:42 UTC
Created attachment 79448 [details]
Fixed screenshot.
Comment 8 André Klapper 2007-04-12 15:33:23 UTC
please change the comment
         Skip the "context-name" part
to
         Ignore the "context-name|" part
. yes, i have my reasons, when grepping through the po files...

and you write "abbreviated to two chars" - what happens if a translator uses three chars instead?
Comment 9 makuchaku (Mayank) 2007-04-13 09:00:59 UTC
Comment on attachment 79447 [details] [review]
Patch for the bug.

>Index: ./widgets/misc/e-calendar-item.c
>===================================================================
>RCS file: /cvs/gnome/evolution/widgets/misc/e-calendar-item.c,v
>retrieving revision 1.53
>diff -u -8 -p -r1.53 e-calendar-item.c
>--- ./widgets/misc/e-calendar-item.c	4 Dec 2006 15:43:45 -0000	1.53
>+++ ./widgets/misc/e-calendar-item.c	5 Jan 2007 14:33:51 -0000
>@@ -32,16 +32,17 @@
> #endif
> 
> #include "e-calendar-item.h"
> #include "ea-widgets.h"
> 
> #include <time.h>
> #include <string.h>
> #include <glib.h>
>+#include <glib/gi18n.h> 		
> #include <gtk/gtkmain.h>
> #include <gtk/gtkmenu.h>
> #include <gtk/gtkmenuitem.h>
> #include <gtk/gtklabel.h>
> #include <gtk/gtksignal.h>
> #include <gdk/gdkkeysyms.h>
> #include <libgnome/gnome-i18n.h>
> #include <libedataserver/e-data-server-util.h>
>@@ -407,19 +408,26 @@ e_calendar_item_init (ECalendarItem *cal
> 	calitem->style_callback_data = NULL;
> 	calitem->style_callback_destroy = NULL;
> 
> 	calitem->time_callback = NULL;
> 	calitem->time_callback_data = NULL;
> 	calitem->time_callback_destroy = NULL;
> 
> 	/* Translators: These are the first characters of each day of the
>-	   week, 'M' for 'Monday', 'T' for Tuesday etc. */
>-	calitem->days = _("MTWTFSS");
>-
>+	   week, 'M' for 'Monday', 'T' for Tuesday etc. Please use as small representation
>+	   for them as possible. Ignore the "context-name" part when translating.*/
>+	calitem->days[0] = Q_("context-Monday|M");
>+	calitem->days[1] = Q_("context-Tuesday|T");
>+	calitem->days[2] = Q_("context-Wednesday|W");
>+	calitem->days[3] = Q_("context-Thursday|T");
>+	calitem->days[4] = Q_("context-Friday|F");
>+	calitem->days[5] = Q_("context-Saturday|S");
>+	calitem->days[6] = Q_("context-Sunday|S");
>+	
> 	calitem->signal_emission_idle_id = 0;
> }
> 
> 
> static void
> e_calendar_item_destroy		(GtkObject *o)
> {
> 	ECalendarItem *calitem;
>@@ -960,28 +968,17 @@ e_calendar_item_draw		(GnomeCanvasItem *
> 
> 	pango_font_metrics_unref (font_metrics);
> }
> 
> 
> static void
> layout_set_day_text (ECalendarItem *calitem, PangoLayout *layout, int day_index)
> {
>-	char *day;
>-	int char_size = 0;
>-
>-	day = g_utf8_offset_to_pointer (calitem->days, day_index);
>-
>-	/* we use strlen because we actually want to count bytes */
>-	if (day_index == 6)
>-		char_size = strlen (day); 
>-	else
>-		char_size = strlen (day) - strlen (g_utf8_find_next_char (day, NULL));
>-
>-	pango_layout_set_text (layout, day, char_size);	
>+	pango_layout_set_text (layout, calitem->days[day_index], -1);
> }
> 
> static void
> e_calendar_item_draw_month	(ECalendarItem   *calitem,
> 				 GdkDrawable	 *drawable,
> 				 int		  x,
> 				 int		  y,
> 				 int		  width,
>@@ -1607,28 +1604,17 @@ e_calendar_item_draw		(GnomeCanvasItem *
> 	pango_font_metrics_unref (font_metrics);
> 	cairo_destroy (cr);
> }
> 
> 
> static void
> layout_set_day_text (ECalendarItem *calitem, PangoLayout *layout, int day_index)
> {
>-	char *day;
>-	int char_size = 0;
>-
>-	day = g_utf8_offset_to_pointer (calitem->days, day_index);
>-
>-	/* we use strlen because we actually want to count bytes */
>-	if (day_index == 6)
>-		char_size = strlen (day); 
>-	else
>-		char_size = strlen (day) - strlen (g_utf8_find_next_char (day, NULL));
>-
>-	pango_layout_set_text (layout, day, char_size);	
>+	pango_layout_set_text (layout, calitem->days[day_index], -1);
> }
> 
> static void
> e_calendar_item_draw_month	(ECalendarItem   *calitem,
> 				 GdkDrawable	 *drawable,
> 				 int		  x,
> 				 int		  y,
> 				 int		  width,
>Index: ./widgets/misc/e-calendar-item.h
>===================================================================
>RCS file: /cvs/gnome/evolution/widgets/misc/e-calendar-item.h,v
>retrieving revision 1.19
>diff -u -8 -p -r1.19 e-calendar-item.h
>--- ./widgets/misc/e-calendar-item.h	28 Apr 2005 08:03:47 -0000	1.19
>+++ ./widgets/misc/e-calendar-item.h	5 Jan 2007 14:33:53 -0000
>@@ -211,18 +211,18 @@ struct _ECalendarItem
> 	gboolean selection_set;
> 	gint selection_start_month_offset;
> 	gint selection_start_day;
> 	gint selection_end_month_offset;
> 	gint selection_end_day;
> 	gint selection_real_start_month_offset;
> 	gint selection_real_start_day;
> 
>-	/* The first character of each day of the week, e.g. 'MTWTFSS'. */
>-	gchar *days;
>+	/* A array of string pointers to hold day names (abbriviated to 2 chars) */
>+	gchar *days[7];
> 
> 	/* Widths of the day characters. */
> 	gint day_widths[7];
> 
> 	/* Widths of the digits, '0' .. '9'. */
> 	gint digit_widths[10];
> 	gint max_digit_width;
> 	gint week_number_digit_widths[10];
>Index: calendar/gui/weekday-picker.c
>===================================================================
>RCS file: /cvs/gnome/evolution/calendar/gui/weekday-picker.c,v
>retrieving revision 1.21
>diff -u -8 -p -r1.21 weekday-picker.c
>--- calendar/gui/weekday-picker.c	8 Feb 2006 13:06:02 -0000	1.21
>+++ calendar/gui/weekday-picker.c	5 Jan 2007 15:04:37 -0000
>@@ -310,30 +310,27 @@ colorize_items (WeekdayPicker *wp)
> 				       NULL);
> 	}
> }
> 
> /* Configures the items in the weekday picker by setting their attributes. */
> static char *
> get_day_text (int day_index)
> {
>-	/* The first letter of each day of the week starting with Sunday */
>-	const char *str = _("SMTWTFS");
>-	char *day;
>-	int char_size = 0;
>-
>-	day = g_utf8_offset_to_pointer (str, day_index);
>-
>-	/* we use strlen because we actually want to count bytes */
>-	if (day_index == 6)
>-		char_size = strlen (day); 
>-	else
>-		char_size = strlen (day) - strlen (g_utf8_find_next_char (day, NULL));
>-
>-	return g_strndup (day, char_size);
>+	/* The first letter of each day of the week */
>+	gchar *days[7];
>+	days[0] = Q_("context-Monday|M");
>+	days[1] = Q_("context-Tuesday|T");
>+	days[2] = Q_("context-Wednesday|W");
>+	days[3] = Q_("context-Thursday|T");
>+	days[4] = Q_("context-Friday|F");
>+	days[5] = Q_("context-Saturday|S");
>+	days[6] = Q_("context-Sunday|S");
>+	
>+	return g_strdup(days[day_index]);
> }
> 
> static void
> configure_items (WeekdayPicker *wp)
> {
> 	WeekdayPickerPrivate *priv;
> 	int width, height;
> 	int box_width;
Comment 10 André Klapper 2007-05-15 15:48:24 UTC
sexy. let's get this in for 2.11 - it would break the string freeze for 2.10.
Comment 11 Akira TAGOH 2007-09-05 11:08:54 UTC
How is this bug going on? apparently this bug isn't yet fixed in any releases of evolution.
Comment 12 André Klapper 2007-09-05 12:35:32 UTC
sigh... a patch for 2.13.1, i hope.
/me pings chen
Comment 13 Matthew Barnes 2007-09-05 18:26:35 UTC
The patch looks okay but I wonder if we could fix this without breaking string freeze.  Mayank stated, "One possible fix is that the code can be modified to pick up values of abbreviated day names from glibc."  That sounds like the better way to go than maintaining our own translations of abbreviated day names.
Comment 14 Milan Crha 2007-10-19 13:56:58 UTC
Created attachment 97477 [details] [review]
proposed evo patch

for evolution;

Added one central place to obtain abbreviations of week day names, it also tries to cut it as much as possible.
Comment 15 huzheng 2007-11-20 05:37:12 UTC
Created attachment 99375 [details] [review]
Fix weekday name problem.

I have created a new patch which get weekday name from glibc.
It compile OK, but I didn't well test it. Can anyone examine and test it for
me?
There are two get_day_text(), when day_index is 0, it means Sunday, which may
be incorret. But I suppose it is better to change the caller function.
The maintainer can help me to incorporate this patch with some modification.
Comment 16 Srinivasa Ragavan 2007-11-26 02:49:04 UTC
Matt, can you close this review? Thanks.
Comment 17 Matthew Barnes 2007-11-27 05:06:06 UTC
I think you can save a few steps by using either e_utf8_strftime() or (preferrably) g_date_strftime() instead of strftime().

See any of the following calendar functions for an example [1]:

   e_week_view_style_set()
   e_week_view_titles_item_draw()
   print_month_summary()
   e_day_view_style_set()
   e_meeting_time_selector_recalc_date_format()

Marking the patch as "Needs Work", though I like what it's doing in principle.


[1] Yes, I'm hinting at the need for a centralized utility function, similar
    to what Milan was thinking.  I don't think it's necessary for this
    particular bug, but the amount of code duplication I'm seeing across
    Evolution is bothersome.  Something like the following might be a nice
    addition to libedataserver or e-utils:

       const gchar *
       e_get_weekday_name (GDateWeekday weekday,
                           gboolean abbreviated);

    And maybe also:

       const gchar *
       e_get_month_name (GDateMonth month,
                         gboolean abbreviated);

    Each function would maintain a static array of localized UTF-8 strings.
Comment 18 Matthew Barnes 2007-11-28 20:08:13 UTC
Created attachment 99799 [details] [review]
Revised patch

This patch implements the e_get_month_name() and e_get_weekday_name() functions described above and utilizes them to fix the immediate bug.  There's several other places in Evolution where they could be substituted for strftime().

Srini/Chen, what do you think?
Comment 19 Chenthill P 2007-12-03 09:23:41 UTC
The patch looks good to commit. Please replace the g_assert with g_return_if_fail and commit them.
Comment 20 Matthew Barnes 2007-12-03 13:27:09 UTC
Committed to trunk (revision 34627).

There's a few other places in Evolution where these new utility functions could simplify the code, so I'm reassigning the bug to myself and leaving it open for now.
Comment 21 Matthew Barnes 2007-12-03 22:56:51 UTC
Created attachment 100151 [details] [review]
Supplemental patch

Here's a few more spots in Evolution where the new utility functions can help simplify things a bit.

I noticed several of those spots are just calculating the widest weekday or month name for a given PangoLayout.  A couple new utility functions could simplify things even further.  Something like:

    gint
    e_get_max_month_width (PangoLayout *layout,
                           gboolean abbreviated);

    gint
    e_get_max_weekday_width (PangoLayout *layout,
                             gboolean abbreviated);
Comment 22 Chenthill P 2007-12-05 09:05:39 UTC
Patch looks good to commit. Please commit the same.
Comment 23 Matthew Barnes 2007-12-05 20:54:21 UTC
Committed to trunk (revision 34659).  Thanks chen.
Comment 24 Nickolay V. Shmyrev 2008-03-19 17:11:03 UTC
*** Bug 523032 has been marked as a duplicate of this bug. ***