GNOME Bugzilla – 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.
Last modified: 2013-09-13 00:54:56 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.
Created attachment 79379 [details] Print preview
Created attachment 79380 [details] Month view Notice the circled day names.
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.
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 "सोमंबुगुशुशर"
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"
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.
Created attachment 79448 [details] Fixed screenshot.
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 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;
sexy. let's get this in for 2.11 - it would break the string freeze for 2.10.
How is this bug going on? apparently this bug isn't yet fixed in any releases of evolution.
sigh... a patch for 2.13.1, i hope. /me pings chen
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.
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.
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.
Matt, can you close this review? Thanks.
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.
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?
The patch looks good to commit. Please replace the g_assert with g_return_if_fail and commit them.
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.
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);
Patch looks good to commit. Please commit the same.
Committed to trunk (revision 34659). Thanks chen.
*** Bug 523032 has been marked as a duplicate of this bug. ***