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 623934 - follow LC_TIME preferred time format when printing time and date
follow LC_TIME preferred time format when printing time and date
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: General
2.31.x
Other Linux
: Normal normal
: ---
Assigned To: empathy-maint
empathy-maint
: 593432 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-07-09 10:55 UTC by Nicolò Chieffo
Modified: 2010-09-14 13:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
diff -u (609 bytes, patch)
2010-07-09 10:55 UTC, Nicolò Chieffo
none Details | Review
patch (using %X for time and %x for date) (607 bytes, patch)
2010-07-13 12:02 UTC, Nicolò Chieffo
rejected Details | Review
patch (818 bytes, patch)
2010-08-09 08:28 UTC, Nicolò Chieffo
reviewed Details | Review

Description Nicolò Chieffo 2010-07-09 10:55:06 UTC
Created attachment 165545 [details] [review]
diff -u

#define EMPATHY_TIME_FORMAT_DISPLAY_SHORT "%H:%M"
#define EMPATHY_TIME_FORMAT_DISPLAY_LONG  "%a %d %b %Y"

This does not follow the locale.
Patch attached.

"regressions":
- seconds are shown
- the date contains the time zone
- EMPATHY_TIME_FORMAT_DISPLAY_LONG will also display the time

I know no other way to get locale formatted things in strftime() even after reading its doc.
Comment 1 Guillaume Desmottes 2010-07-09 11:37:42 UTC
(In reply to comment #0)
> - EMPATHY_TIME_FORMAT_DISPLAY_LONG will also display the time

Can't we use 
%x     The preferred date representation for the current locale without the time.

?
Comment 2 Xavier Claessens 2010-07-09 11:42:51 UTC
Where do you see non local time displayed? Just use empathy_time_to_string_local()
Comment 3 Nicolò Chieffo 2010-07-09 11:51:48 UTC
Guillaume Desmottes: yes that seems good (although %x shows the date in numeric format).

Xavier Claessens: empathy_time_to_string_local() has a "format" parameter, which won't follow the locale (just LC_TIME translations) unless a strftime %x, %X or %c is used
Comment 4 Nicolò Chieffo 2010-07-13 12:02:29 UTC
Created attachment 165793 [details] [review]
patch (using %X for time and %x for date)
Comment 5 Nicolò Chieffo 2010-07-17 08:52:08 UTC
Another possible approach would be to use gettext.
put the standard engligh format:
#define EMPATHY_TIME_FORMAT_DISPLAY_SHORT _("%I:%M %p")
#define EMPATHY_TIME_FORMAT_DISPLAY_LONG   _("%a %b %d %Y")
 
Then translators will have to translate these strings accordingly to their locale.
Comment 6 Guillaume Desmottes 2010-08-02 08:59:53 UTC
I'd keep the current format ("%H:%M" and "%a %d %b %Y") and would just make them translatable.
Could you please cook a patch doing that? Please include a translator comment as well to give them some explanations of the context.
Comment 7 Nicolò Chieffo 2010-08-08 07:58:10 UTC
What is a translator comment? Is it just a normal comment before the code, such as

/* translators should use the preferred time format (without seconds) corresponding to their locale */

/* translators should use the preferred date format (using abbreviated names for month and weekday) corresponding to their locale */
Comment 8 Guillaume Desmottes 2010-08-09 08:18:47 UTC
You should use this format so the comment appears in the po file:
/* Translators: badger badger */

I'd also mention how to get the list of supported formats (man strftime).
Comment 9 Nicolò Chieffo 2010-08-09 08:28:20 UTC
Created attachment 167405 [details] [review]
patch

Thanks for the quick answer. This could be a possible patch, but I couldn't test it because I'm missing some libraries to compile the git version and I don't want to mess with them.

I don't know gettext, so please tell me if other things must be done.
Comment 10 Guillaume Desmottes 2010-08-09 08:46:25 UTC
Review of attachment 167405 [details] [review]:

::: libempathy/empathy-time.h
@@ +38,3 @@
+#define EMPATHY_TIME_FORMAT_DISPLAY_SHORT _("%H:%M")
+#define EMPATHY_DATE_FORMAT_DISPLAY_SHORT  _("%a %d %b %Y")
+#define EMPATHY_TIME_DATE_FORMAT_DISPLAY_SHORT _("%a %d %b %Y, %H:%M")

What's the advantage to use that instead of %c ? According to the doc:
"       %c     The preferred date and time representation for the current locale."
so we shouldn't have to translate this one.
Comment 11 Nicolò Chieffo 2010-08-09 08:54:12 UTC
%c also shows the timezone which is definitely not a needed thing
Comment 12 Guillaume Desmottes 2010-08-09 11:26:28 UTC
Good point. I merged your branch to master. Thanks a lot for your work on this.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.

commit 8f599de3f64c57848bb27c6fdbc26c47337530fc
Author: Nicolò Chieffo <84yelo3@gmail.com>
Date:   Mon Aug 9 13:25:11 2010 +0200

    Allow translators to localize time formats (#623934)
Comment 13 Guillaume Desmottes 2010-09-14 13:26:56 UTC
*** Bug 593432 has been marked as a duplicate of this bug. ***