aboutsummaryrefslogtreecommitdiffstats
path: root/agent/genkey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-06-30 19:58:02 +0000
committerWerner Koch <[email protected]>2015-06-30 19:58:45 +0000
commite76d4c05b24211f3981ab69cddb3fccc17d21e0e (patch)
treef62e615bffca562ef096cb8babd9e8c2b70379d5 /agent/genkey.c
parentRemove obsolete file g10/comment.c. (diff)
downloadgnupg-e76d4c05b24211f3981ab69cddb3fccc17d21e0e.tar.gz
gnupg-e76d4c05b24211f3981ab69cddb3fccc17d21e0e.zip
agent: Use different translation func for Pinentry strings.
* po/Makevars (XGETTEXT_OPTIONS): Add keyword "L_". * common/i18n.c (i18n_localegettext): New stub. * common/i18n.h: Expand the LunderscoreIMPL macro. * agent/agent.h (L_): New. (LunderscoreIMPL): New. * agent/call-pinentry.c (setup_qualitybar): Add arg ctrl anc change caller. * agent/findkey.c (try_unprotect_cb): Add local var ctrl. * agent/genkey.c (check_passphrase_constraints): Replace xtryasprintf by xtrystrdup to avoid gcc warning. Unfortinately this changes the string. (agent_ask_new_passphrase): Cleanup the use of initial_errtext. -- Static strings in gpg-agent need to be translated according to the locale set by the caller. This is required so that a gpg-agent can be started in one locale and a gpg can be run in another. If we don't do this the static strings (prompt, buttons) are not or in the wrong locale translated while dynamic strings (e.g. key description) uses the locale of gpg. This is only the first part of the change the actual local switching still needs to be implemented. Debian-bug-id: 788983 Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/genkey.c')
-rw-r--r--agent/genkey.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/agent/genkey.c b/agent/genkey.c
index 85b8aba7e..b5dee8ee5 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -155,13 +155,13 @@ take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn)
if (opt.enforce_passphrase_constraints)
{
- err = agent_show_message (ctrl, desc, _("Enter new passphrase"));
+ err = agent_show_message (ctrl, desc, L_("Enter new passphrase"));
if (!err)
err = gpg_error (GPG_ERR_CANCELED);
}
else
err = agent_get_confirmation (ctrl, desc,
- anyway_btn, _("Enter new passphrase"), 0);
+ anyway_btn, L_("Enter new passphrase"), 0);
return err;
}
@@ -169,7 +169,7 @@ take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn)
static int
take_this_one_anyway (ctrl_t ctrl, const char *desc)
{
- return take_this_one_anyway2 (ctrl, desc, _("Take this one anyway"));
+ return take_this_one_anyway2 (ctrl, desc, L_("Take this one anyway"));
}
@@ -196,12 +196,12 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw,
if (!*pw)
{
const char *desc = (opt.enforce_passphrase_constraints?
- _("You have not entered a passphrase!%0A"
- "An empty passphrase is not allowed.") :
- _("You have not entered a passphrase - "
- "this is in general a bad idea!%0A"
- "Please confirm that you do not want to "
- "have any protection on your key."));
+ L_("You have not entered a passphrase!%0A"
+ "An empty passphrase is not allowed.") :
+ L_("You have not entered a passphrase - "
+ "this is in general a bad idea!%0A"
+ "Please confirm that you do not want to "
+ "have any protection on your key."));
err = 1;
if (failed_constraint)
@@ -210,7 +210,7 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw,
*failed_constraint = xstrdup (desc);
else
err = take_this_one_anyway2 (ctrl, desc,
- _("Yes, protection is not needed"));
+ L_("Yes, protection is not needed"));
}
goto leave;
@@ -271,9 +271,8 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw,
goto leave;
}
- msg3 = xtryasprintf
- (_("A passphrase may not be a known term or match%%0A"
- "certain pattern."));
+ msg3 = xtrystrdup (L_("A passphrase may not be a known term or match%0A"
+ "certain pattern."));
if (!msg3)
{
err = gpg_error_from_syserror ();
@@ -287,7 +286,7 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw,
size_t n;
msg = strconcat
- (_("Warning: You have entered an insecure passphrase."),
+ (L_("Warning: You have entered an insecure passphrase."),
"%0A%0A",
msg1? msg1 : "", msg1? "%0A" : "",
msg2? msg2 : "", msg2? "%0A" : "",
@@ -345,9 +344,8 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
{
gpg_error_t err;
const char *text1 = prompt;
- const char *text2 = _("Please re-enter this passphrase");
+ const char *text2 = L_("Please re-enter this passphrase");
char *initial_errtext = NULL;
- int initial_errtext_do_free = 0;
struct pin_entry_info_s *pi, *pi2;
*r_passphrase = NULL;
@@ -385,17 +383,12 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
next_try:
err = agent_askpin (ctrl, text1, NULL, initial_errtext, pi, NULL, 0);
- if (initial_errtext_do_free)
- {
- xfree (initial_errtext);
- initial_errtext_do_free = 0;
- }
+ xfree (initial_errtext);
initial_errtext = NULL;
if (!err)
{
if (check_passphrase_constraints (ctrl, pi->pin, &initial_errtext))
{
- initial_errtext_do_free = 1;
pi->failed_tries = 0;
pi2->failed_tries = 0;
goto next_try;
@@ -408,8 +401,10 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
if (err == -1)
{ /* The re-entered one did not match and the user did not
hit cancel. */
- initial_errtext = _("does not match - try again");
- goto next_try;
+ initial_errtext = xtrystrdup (L_("does not match - try again"));
+ if (initial_errtext)
+ goto next_try;
+ err = gpg_error_from_syserror ();
}
}
}
@@ -421,6 +416,8 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
if (!*r_passphrase)
err = gpg_error_from_syserror ();
}
+
+ xfree (initial_errtext);
xfree (pi);
return err;
}
@@ -467,8 +464,8 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
else
{
rc = agent_ask_new_passphrase (ctrl,
- _("Please enter the passphrase to%0A"
- "protect your new key"),
+ L_("Please enter the passphrase to%0A"
+ "protect your new key"),
&passphrase_buffer);
if (rc)
return rc;
@@ -593,7 +590,7 @@ agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
*passphrase_addr = NULL;
}
err = agent_ask_new_passphrase (ctrl,
- _("Please enter the new passphrase"),
+ L_("Please enter the new passphrase"),
&pass);
if (!err)
err = store_key (s_skey, pass, 1, ctrl->s2k_count);