summaryrefslogtreecommitdiff
path: root/src/json
diff options
context:
space:
mode:
Diffstat (limited to 'src/json')
-rw-r--r--src/json/json_helper.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 2a9b01a7..b39500f7 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -380,7 +380,7 @@ struct I18nContext
/**
* Language pattern to match.
*/
- const char *lp;
+ char *lp;
/**
* Name of the field to match.
@@ -466,6 +466,7 @@ i18n_cleaner (void *cls,
{
struct I18nContext *ctx = cls;
+ GNUNET_free (ctx->lp);
GNUNET_free (ctx);
}
@@ -486,7 +487,7 @@ TALER_JSON_spec_i18n_string (const char *name,
.size_ptr = NULL
};
- ctx->lp = language_pattern;
+ ctx->lp = GNUNET_strdup (language_pattern);
ctx->field = name;
*strptr = NULL;
return ret;
@@ -497,9 +498,30 @@ 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);
+ const char *lang = getenv ("LANG");
+ char *dot;
+ char *l;
+ struct GNUNET_JSON_Specification ret;
+
+ if (NULL != lang)
+ {
+ dot = strchr (lang,
+ '.');
+ if (NULL == dot)
+ l = GNUNET_strdup (lang);
+ else
+ l = GNUNET_strndup (lang,
+ dot - lang);
+ }
+ else
+ {
+ l = NULL;
+ }
+ ret = TALER_JSON_spec_i18n_string (name,
+ l,
+ strptr);
+ GNUNET_free (l);
+ return ret;
}