gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: implement convenience function t


From: gnunet
Subject: [taler-exchange] branch master updated: implement convenience function to extract i18n values from JSON (for #6749)
Date: Mon, 05 Apr 2021 18:40:26 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 004a7c9d implement convenience function to extract i18n values from 
JSON (for #6749)
004a7c9d is described below

commit 004a7c9d5447de29972af560765791066c198226
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Apr 5 18:40:23 2021 +0200

    implement convenience function to extract i18n values from JSON (for #6749)
---
 src/include/taler_json_lib.h | 39 +++++++++++++++++++++++++++++++++++++++
 src/json/json_helper.c       | 10 ++++++++++
 2 files changed, 49 insertions(+)

diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index a1e4d883..f61e2c0f 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -141,6 +141,45 @@ TALER_JSON_spec_denomination_signature (const char *field,
                                         struct TALER_DenominationSignature 
*sig);
 
 
+/**
+ * The expected field stores a possibly internationalized string.
+ * Internationalization means that there is another field "$name_i18n"
+ * which is an object where the keys are languages.  If this is
+ * present, and if @a language_pattern is non-NULL, this function
+ * should return the best match from @a language pattern from the
+ * "_i18n" field.  If no language matches, the normal field under
+ * @a name is to be returned.
+ *
+ * The @a language_pattern is given using the format from
+ * https://tools.ietf.org/html/rfc7231#section-5.3.1
+ * so that #TALER_language_matches() can be used.
+ *
+ * @param name name of the JSON field
+ * @param language_pattern language pattern to use to find best match, 
possibly NULL
+ * @param[out] strptr where to store a pointer to the field with the best 
variant
+ */
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_i18n_string (const char *name,
+                             const char *language_pattern,
+                             const char **strptr);
+
+
+/**
+ * The expected field stores a possibly internationalized string.
+ * Internationalization means that there is another field "$name_i18n" which
+ * is an object where the keys are languages.  If this is present, this
+ * function should return the best match based on the locale from the "_i18n"
+ * field.  If no language matches, the normal field under @a name is to be
+ * returned.
+ *
+ * @param name name of the JSON field
+ * @param[out] strptr where to store a pointer to the field with the best 
variant
+ */
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_i18n_str (const char *name,
+                          const char **strptr);
+
+
 /**
  * Hash a JSON for binary signing.
  *
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index f3070588..2a9b01a7 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -493,4 +493,14 @@ TALER_JSON_spec_i18n_string (const char *name,
 }
 
 
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_i18n_str (const char *name,
+                          const char **strptr)
+{
+  return TALER_JSON_spec_i18n_string (name,
+                                      getenv ("LANG"),
+                                      strptr);
+}
+
+
 /* end of json/json_helper.c */

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]