aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-04-05 19:27:19 +0200
committerChristian Grothoff <christian@grothoff.org>2021-04-05 19:27:19 +0200
commit63c6654c0f41b8a8d9c436c2735e7392dd2b59bf (patch)
tree39989af2c88080bfcb59c229490e06d09f52d6b5
parent004a7c9d5447de29972af560765791066c198226 (diff)
omit charset from en_US.UTF-8 env variable when picking i18n strings
-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 2a9b01a75..b39500f75 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;
}