[glib-networking] gnutls: Use ngettext where required



commit 57f8d0602b7f02bde7614d44c5d858844d352434
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Thu Nov 2 14:22:50 2017 -0500

    gnutls: Use ngettext where required
    
    This looks pretty odd in English, as we know the MTU and message size
    will never be 0 in these error messages, and so the string will never be
    singular. But all the world is not English.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789833

 tls/gnutls/gtlsconnection-gnutls.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 82fd136..2579fa5 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -991,10 +991,10 @@ end_gnutls_io (GTlsConnectionGnutls  *gnutls,
     }
   else if (status == GNUTLS_E_LARGE_PACKET)
     {
+      guint mtu = gnutls_dtls_get_data_mtu (gnutls->priv->session);
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_MESSAGE_TOO_LARGE,
-                   _("Message is too large for DTLS connection; maximum is "
-                     "%u bytes"),
-                   gnutls_dtls_get_data_mtu (gnutls->priv->session));
+                   ngettext ("Message is too large for DTLS connection; maximum is %u byte",
+                             "Message is too large for DTLS connection; maximum is %u bytes", mtu), mtu);
       return status;
     }
   else if (status == GNUTLS_E_TIMEDOUT)
@@ -2415,12 +2415,20 @@ g_tls_connection_gnutls_write_message (GTlsConnectionGnutls  *gnutls,
   if (gnutls->priv->base_socket != NULL &&
       gnutls_dtls_get_data_mtu (gnutls->priv->session) < total_message_size)
     {
+      char *message;
+      guint mtu = gnutls_dtls_get_data_mtu (gnutls->priv->session);
+
       ret = GNUTLS_E_LARGE_PACKET;
+      message = g_strdup_printf("%s %s",
+                                ngettext ("Message of size %lu byte is too large for DTLS connection",
+                                          "Message of size %lu bytes is too large for DTLS connection", 
total_message_size),
+                                ngettext ("(maximum is %u byte)", "(maximum is %u bytes)", mtu));
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_MESSAGE_TOO_LARGE,
-                   _("Message of size %lu bytes is too large for "
-                     "DTLS connection, maximum is %u bytes"),
+                   message,
                    total_message_size,
-                   (guint) gnutls_dtls_get_data_mtu (gnutls->priv->session));
+                   mtu);
+      g_free (message);
+
       goto done;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]