[recipes] Move a translation helper function to utils



commit 807f972ab3fe0ad80194a11bb667865ac56dfc03
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 2 06:14:45 2017 -0500

    Move a translation helper function to utils
    
    This will be used in multiple places.

 src/gr-utils.c |   23 +++++++++++++++++++++++
 src/gr-utils.h |    3 +--
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 5ce9d95..2b0083b 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -20,6 +20,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n.h>
 #include <stdlib.h>
 
 #include "gr-utils.h"
@@ -304,3 +305,25 @@ space_or_nul (char p)
 {
         return (p == '\0' || g_ascii_isspace (p));
 }
+
+/* this is for translating strings that have been extracted using recipe-extract */
+char *
+translate_multiline_string (const char *s)
+{
+        g_auto(GStrv) strv = NULL;
+        int i;
+        GString *out;
+
+        out = g_string_new ("");
+
+        strv = g_strsplit (s, "\n", -1);
+
+        for (i = 0; strv[i]; i++) {
+                if (i > 0)
+                        g_string_append (out, "\n");
+                if (strv[i][0] != 0)
+                        g_string_append (out, _(strv[i]));
+        }
+
+        return g_string_free (out, FALSE);
+}
diff --git a/src/gr-utils.h b/src/gr-utils.h
index 3b0ad13..79807d5 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -48,5 +48,4 @@ GDateTime * date_time_from_string (const char *string);
 gboolean skip_whitespace (char **input);
 gboolean space_or_nul    (char p);
 
-
-G_END_DECLS
+char *translate_multiline_string (const char *s);


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