aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-06-02 10:42:59 +0000
committerWerner Koch <[email protected]>2025-06-02 10:42:59 +0000
commite6463d7fe097b39c9e8952ef9f5758fa0ee0e4bd (patch)
tree38222b8338276d8de0b92130dd43b003ec46754c /common
parentgpg-mail-tube: Support templates. (diff)
downloadgnupg-e6463d7fe097b39c9e8952ef9f5758fa0ee0e4bd.tar.gz
gnupg-e6463d7fe097b39c9e8952ef9f5758fa0ee0e4bd.zip
wks: Use templates for the server responses.
* common/helpfile.c (gnupg_get_template): Add arg locale_override and adjust all callers. * tools/wks-receive.c (struct receive_ctx_s): Add field ct_language. (get_language): New. (new_part): Call it. (wks_receive): Pass language to the result callback. * tools/gpg-wks-client.c (short_locale): New. (main): Get and store the current locale. (command_create): Fix a glitch for the Posteo hack. Insert the locale into the confirmation request. (send_confirmation_response): Ditto. * tools/gpg-wks-server.c (struct server_ctx_s): Add field language. (only_ascii): New. (struct my_subst_vars_s, my_subst_vars_cb, my_subst_vars): New. (send_confirmation_request): Use a template. (send_congratulation_message): Ditto. (check_and_publish): Pss ctx to send_congratulation_message. (command_receive_cb): Add arg language. * doc/wks-utils.txt, doc/wks-utils.de.txt: New. * doc/Makefile.am (helpfiles): Add them. -- GnuPG-bug-id: 7381 Note that the subject is not yet translated or templated due to a missing header encoding function.
Diffstat (limited to 'common')
-rw-r--r--common/helpfile.c22
-rw-r--r--common/t-helpfile.c2
-rw-r--r--common/util.h2
3 files changed, 17 insertions, 9 deletions
diff --git a/common/helpfile.c b/common/helpfile.c
index 956ec2516..240562794 100644
--- a/common/helpfile.c
+++ b/common/helpfile.c
@@ -234,21 +234,25 @@ findkey_locale (const char *domain, const char *key, const char *locname,
intervening lines (except for comment lines) lead to the same help
text. Lines following the key lines make up the actual template texts.
*/
-
char *
-gnupg_get_template (const char *domain, const char *key, unsigned int flags)
+gnupg_get_template (const char *domain, const char *key, unsigned int flags,
+ const char *override_locale)
{
- static const char *locname;
+ static const char *locname_buffer;
+ const char *locname;
char *result;
- if (!locname)
+ if (override_locale && *override_locale)
+ locname = override_locale;
+ else if (!locname_buffer)
{
char *buffer, *p;
int count = 0;
const char *s = gnupg_messages_locale_name ();
+
buffer = xtrystrdup (s);
if (!buffer)
- locname = "";
+ locname_buffer = "";
else
{
for (p = buffer; *p; p++)
@@ -259,9 +263,12 @@ gnupg_get_template (const char *domain, const char *key, unsigned int flags)
if (count++)
*p = 0; /* Also cut at an underscore in the territory. */
}
- locname = buffer;
+ locname_buffer = buffer;
}
+ locname = locname_buffer;
}
+ else
+ locname = locname_buffer;
if (!key || !*key)
return NULL;
@@ -293,5 +300,6 @@ char *
gnupg_get_help_string (const char *key, int only_current)
{
return gnupg_get_template ("help", key,
- only_current? GET_TEMPLATE_CURRENT_LOCALE : 0);
+ only_current? GET_TEMPLATE_CURRENT_LOCALE : 0,
+ NULL);
}
diff --git a/common/t-helpfile.c b/common/t-helpfile.c
index adb69ba2d..d1e7f547d 100644
--- a/common/t-helpfile.c
+++ b/common/t-helpfile.c
@@ -66,7 +66,7 @@ main (int argc, char **argv)
}
- result = gnupg_get_template (argv[0], argv[1], flags);
+ result = gnupg_get_template (argv[0], argv[1], flags, NULL);
if (!result)
{
fprintf (stderr,
diff --git a/common/util.h b/common/util.h
index ce1dc37d8..b81664c3e 100644
--- a/common/util.h
+++ b/common/util.h
@@ -303,7 +303,7 @@ void gnupg_rl_initialize (void);
#define GET_TEMPLATE_CRLF 4 /* Use CR+LF. */
char *gnupg_get_template (const char *domain, const char *key,
- unsigned int flags);
+ unsigned int flags, const char *override_locale);
char *gnupg_get_help_string (const char *key, int only_current_locale);
/*-- localename.c --*/