changeset 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 ef1b5208bda9
children 44a4bd35cc97
files src/util.c
diffstat 1 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.c	Thu Feb 02 18:44:29 2006 +0000
+++ b/src/util.c	Thu Feb 02 18:48:32 2006 +0000
@@ -2698,17 +2698,12 @@
 char *
 gaim_str_seconds_to_string(guint secs)
 {
-	GString *gstr;
-	const char *prefix = "";
+	char *ret = NULL;
 	guint days, hrs, mins;
 
-	gstr = g_string_new("");
-
 	if (secs < 60)
 	{
-		g_string_append_printf(gstr, "%d %s", secs,
-							   ngettext("second", "seconds", secs));
-		return g_string_free(gstr, FALSE);
+		return g_strdup_printf(ngettext("%d second", "%d seconds", secs), secs);
 	}
 
 	days = secs / (60 * 60 * 24);
@@ -2720,27 +2715,38 @@
 
 	if (days > 0)
 	{
-		g_string_append_printf(gstr, "%d %s", days,
-							   ngettext("day", "days", days));
-
-		prefix = ", ";
+		ret = g_strdup_printf(ngettext("%d day", "%d days", days), days);
 	}
 
 	if (hrs > 0)
 	{
-		g_string_append_printf(gstr, "%s%d %s", prefix, hrs,
-							   ngettext("hour", "hours", hrs));
-
-		prefix = ", ";
+		if (ret != NULL)
+		{
+			char *tmp = g_strdup_printf(
+					ngettext("%s, %d hour", "%s, %d hours", hrs),
+							ret, hrs);
+			g_free(ret);
+			ret = tmp;
+		}
+		else
+			ret = g_strdup_printf(ngettext("%d hour", "%d hours", hrs), hrs);
 	}
 
 	if (mins > 0)
 	{
-		g_string_append_printf(gstr, "%s%d %s", prefix, mins,
-							   ngettext("minute", "minutes", mins));
+		if (ret != NULL)
+		{
+			char *tmp = g_strdup_printf(
+					ngettext("%s, %d minute", "%s, %d minutes", mins),
+							ret, mins);
+			g_free(ret);
+			ret = tmp;
+		}
+		else
+			ret = g_strdup_printf(ngettext("%d minute", "%d minutes", mins), mins);
 	}
 
-	return g_string_free(gstr, FALSE);
+	return ret;
 }