GNOME Bugzilla – Bug 623934
follow LC_TIME preferred time format when printing time and date
Last modified: 2010-09-14 13:26:56 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.
(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. ?
Where do you see non local time displayed? Just use empathy_time_to_string_local()
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
Created attachment 165793 [details] [review] patch (using %X for time and %x for date)
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.
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.
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 */
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).
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.
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.
%c also shows the timezone which is definitely not a needed thing
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)
*** Bug 593432 has been marked as a duplicate of this bug. ***