Mercurial > pidgin
comparison src/util.c @ 13097:f1bf8989bbf2
[gaim-migrate @ 15459]
Cleanup the way we mark things for translation in gaim_str_seconds_to_string().
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Thu, 02 Feb 2006 18:48:32 +0000 |
parents | 5a7c4570d768 |
children | 5828d42e8684 |
comparison
equal
deleted
inserted
replaced
13096:ef1b5208bda9 | 13097:f1bf8989bbf2 |
---|---|
2696 } | 2696 } |
2697 | 2697 |
2698 char * | 2698 char * |
2699 gaim_str_seconds_to_string(guint secs) | 2699 gaim_str_seconds_to_string(guint secs) |
2700 { | 2700 { |
2701 GString *gstr; | 2701 char *ret = NULL; |
2702 const char *prefix = ""; | |
2703 guint days, hrs, mins; | 2702 guint days, hrs, mins; |
2704 | |
2705 gstr = g_string_new(""); | |
2706 | 2703 |
2707 if (secs < 60) | 2704 if (secs < 60) |
2708 { | 2705 { |
2709 g_string_append_printf(gstr, "%d %s", secs, | 2706 return g_strdup_printf(ngettext("%d second", "%d seconds", secs), secs); |
2710 ngettext("second", "seconds", secs)); | |
2711 return g_string_free(gstr, FALSE); | |
2712 } | 2707 } |
2713 | 2708 |
2714 days = secs / (60 * 60 * 24); | 2709 days = secs / (60 * 60 * 24); |
2715 secs = secs % (60 * 60 * 24); | 2710 secs = secs % (60 * 60 * 24); |
2716 hrs = secs / (60 * 60); | 2711 hrs = secs / (60 * 60); |
2718 mins = secs / 60; | 2713 mins = secs / 60; |
2719 secs = secs % 60; | 2714 secs = secs % 60; |
2720 | 2715 |
2721 if (days > 0) | 2716 if (days > 0) |
2722 { | 2717 { |
2723 g_string_append_printf(gstr, "%d %s", days, | 2718 ret = g_strdup_printf(ngettext("%d day", "%d days", days), days); |
2724 ngettext("day", "days", days)); | |
2725 | |
2726 prefix = ", "; | |
2727 } | 2719 } |
2728 | 2720 |
2729 if (hrs > 0) | 2721 if (hrs > 0) |
2730 { | 2722 { |
2731 g_string_append_printf(gstr, "%s%d %s", prefix, hrs, | 2723 if (ret != NULL) |
2732 ngettext("hour", "hours", hrs)); | 2724 { |
2733 | 2725 char *tmp = g_strdup_printf( |
2734 prefix = ", "; | 2726 ngettext("%s, %d hour", "%s, %d hours", hrs), |
2727 ret, hrs); | |
2728 g_free(ret); | |
2729 ret = tmp; | |
2730 } | |
2731 else | |
2732 ret = g_strdup_printf(ngettext("%d hour", "%d hours", hrs), hrs); | |
2735 } | 2733 } |
2736 | 2734 |
2737 if (mins > 0) | 2735 if (mins > 0) |
2738 { | 2736 { |
2739 g_string_append_printf(gstr, "%s%d %s", prefix, mins, | 2737 if (ret != NULL) |
2740 ngettext("minute", "minutes", mins)); | 2738 { |
2741 } | 2739 char *tmp = g_strdup_printf( |
2742 | 2740 ngettext("%s, %d minute", "%s, %d minutes", mins), |
2743 return g_string_free(gstr, FALSE); | 2741 ret, mins); |
2742 g_free(ret); | |
2743 ret = tmp; | |
2744 } | |
2745 else | |
2746 ret = g_strdup_printf(ngettext("%d minute", "%d minutes", mins), mins); | |
2747 } | |
2748 | |
2749 return ret; | |
2744 } | 2750 } |
2745 | 2751 |
2746 | 2752 |
2747 char * | 2753 char * |
2748 gaim_str_binary_to_ascii(const unsigned char *binary, guint len) | 2754 gaim_str_binary_to_ascii(const unsigned char *binary, guint len) |