summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_json_lib.h39
-rw-r--r--src/json/json_helper.c10
2 files changed, 49 insertions, 0 deletions
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
@@ -142,6 +142,45 @@ TALER_JSON_spec_denomination_signature (const char *field,
/**
+ * 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.
*
* See https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-15
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 */