summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-19 18:19:00 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-19 18:19:00 +0200
commit46dde9368f75013b2383c24d4c8a11763ac8e31e (patch)
tree7971e4bdd18a951521e4317b1619ecbabbc15a8c /src/include
parenta84c61dd82b17bc42593e5fd358cd0917d195f4f (diff)
downloadexchange-46dde9368f75013b2383c24d4c8a11763ac8e31e.tar.gz
exchange-46dde9368f75013b2383c24d4c8a11763ac8e31e.tar.bz2
exchange-46dde9368f75013b2383c24d4c8a11763ac8e31e.zip
implement i18n lookup logic for #6458
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_json_lib.h31
-rw-r--r--src/include/taler_mhd_lib.h16
-rw-r--r--src/include/taler_util.h16
3 files changed, 47 insertions, 16 deletions
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 171b3d009..a1e4d8830 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -294,6 +294,37 @@ TALER_JSON_exchange_wire_signature_make (
/**
+ * Extract a string from @a object under the field @a field, but respecting
+ * the Taler i18n rules and the language preferences expressed in @a
+ * language_pattern.
+ *
+ * Basically, the @a object may optionally contain a sub-object
+ * "${field}_i18n" with a map from IETF BCP 47 language tags to a localized
+ * version of the string. If this map exists and contains an entry that
+ * matches the @a language pattern, that object (usually a string) is
+ * returned. If the @a language_pattern does not match any entry, or if the
+ * i18n sub-object does not exist, we simply return @a field of @a object
+ * (also usually a string).
+ *
+ * If @a object does not have a member @a field we return NULL (error).
+ *
+ * @param object the object to extract internationalized
+ * content from
+ * @param language_pattern a language preferences string
+ * like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1", following
+ * https://tools.ietf.org/html/rfc7231#section-5.3.1
+ * @param field name of the field to extract
+ * @return NULL on error, otherwise the member from
+ * @a object. Note that the reference counter is
+ * NOT incremented.
+ */
+const json_t *
+TALER_JSON_extract_i18n (const json_t *object,
+ const char *language_pattern,
+ const char *field);
+
+
+/**
* Obtain the wire method associated with the given
* wire account details. @a wire_s must contain a payto://-URL
* under 'url'.
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index 7d281662d..4b34f41df 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -97,22 +97,6 @@ TALER_MHD_can_compress (struct MHD_Connection *connection);
/**
- * Check if @a lang matches the @a language_pattern, and if so with
- * which preference.
- * See also: https://tools.ietf.org/html/rfc7231#section-5.3.1
- *
- * @param language_pattern a language preferences string
- * like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1"
- * @param lang the 2-digit language to match
- * @return q-weight given for @a lang in @a language_pattern, 1.0 if no weights are given;
- * 0 if @a lang is not in @a language_pattern
- */
-double
-TALER_MHD_language_matches (const char *language_pattern,
- const char *lang);
-
-
-/**
* Send JSON object as response.
*
* @param connection the MHD connection
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index 1d1c01eaf..2a64fe8e9 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -185,6 +185,22 @@ TALER_urlencode (const char *s);
/**
+ * Check if @a lang matches the @a language_pattern, and if so with
+ * which preference.
+ * See also: https://tools.ietf.org/html/rfc7231#section-5.3.1
+ *
+ * @param language_pattern a language preferences string
+ * like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1"
+ * @param lang the 2-digit language to match
+ * @return q-weight given for @a lang in @a language_pattern, 1.0 if no weights are given;
+ * 0 if @a lang is not in @a language_pattern
+ */
+double
+TALER_language_matches (const char *language_pattern,
+ const char *lang);
+
+
+/**
* Find out if an MHD connection is using HTTPS (either
* directly or via proxy).
*