From ae958db7586327f82f6951f1527840a9d6e9bef7 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Sun, 3 Jan 2021 14:31:47 +0000 Subject: [PATCH] Better tooltips --- src/rugby-possibility-widget.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/rugby-possibility-widget.c b/src/rugby-possibility-widget.c index 608af8d..b5f4870 100644 --- a/src/rugby-possibility-widget.c +++ b/src/rugby-possibility-widget.c @@ -7,6 +7,8 @@ #include "config.h" #include "rugby-possibility-widget.h" +#include <glib/gi18n.h> + struct _RugbyPossibilityWidget { GtkDrawingArea parent_instance; @@ -155,16 +157,27 @@ rugby_possibility_widget_constructed (GObject *obj) "kicks", &kicks, NULL); - if (tries > 0 || utries > 0) - g_string_append_printf (tooltip, "%d tries, %d converted", + if ((tries + utries) > 0) + { + g_string_append_printf (tooltip, + ngettext ("%d try, %d converted", + "%d tries, %d converted", + tries + utries), tries + utries, tries); - if (kicks > 0) + if (kicks > 0) + g_string_append_printf (tooltip, + ngettext (", %d kick", + ", %d kicks", + kicks), + kicks); + } + else if (kicks > 0) { - if (tooltip->len == 0) - g_string_append_printf (tooltip, "%d kicks", kicks); - else - g_string_append_printf (tooltip, ", %d kicks", kicks); + g_string_append_printf (tooltip, + ngettext ("%d kick", + "%d kicks", kicks), + kicks); } gtk_widget_set_tooltip_text (GTK_WIDGET (self), tooltip->str); -- GitLab