diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/helpfile.c | 19 | ||||
-rw-r--r-- | common/i18n.c | 2 | ||||
-rw-r--r-- | common/t-helpfile.c | 3 | ||||
-rw-r--r-- | common/util.h | 2 |
4 files changed, 16 insertions, 10 deletions
diff --git a/common/helpfile.c b/common/helpfile.c index c1f84a364..3a98055bb 100644 --- a/common/helpfile.c +++ b/common/helpfile.c @@ -149,7 +149,8 @@ findkey_fname (const char *key, const char *fname) /* Try the help files depending on the locale. */ static char * -findkey_locale (const char *key, const char *locname, const char *dirname) +findkey_locale (const char *key, const char *locname, + int only_current_locale, const char *dirname) { const char *s; char *fname, *ext, *p; @@ -182,9 +183,9 @@ findkey_locale (const char *key, const char *locname, const char *dirname) result = NULL; } - if (!result) + if (!result && (!only_current_locale || !*locname) ) { - /* Last try: Search in file without any local info. ("help.txt") */ + /* Last try: Search in file without any locale info. ("help.txt") */ strcpy (ext, "txt"); result = findkey_fname (key, fname); } @@ -205,6 +206,8 @@ findkey_locale (const char *key, const char *locname, const char *dirname) /usr/share/gnupg/help.txt Here LL denotes the two digit language code of the current locale. + If ONLY_CURRENT_LOCALE is set, the fucntion won;t fallback to the + english valiant ("help.txt") unless that locale has been requested. The help file needs to be encoded in UTF-8, lines with a '#' in the first column are comment lines and entirely ignored. Help keys are @@ -216,7 +219,7 @@ findkey_locale (const char *key, const char *locname, const char *dirname) */ char * -gnupg_get_help_string (const char *key) +gnupg_get_help_string (const char *key, int only_current_locale) { static const char *locname; char *result; @@ -237,7 +240,7 @@ gnupg_get_help_string (const char *key) else if (*p == '_') { if (count++) - *p = 0; /* Altho cut at a underscore in the territory. */ + *p = 0; /* Also cut at a underscore in the territory. */ } locname = buffer; } @@ -246,9 +249,11 @@ gnupg_get_help_string (const char *key) if (!key || !*key) return NULL; - result = findkey_locale (key, locname, gnupg_sysconfdir ()); + result = findkey_locale (key, locname, only_current_locale, + gnupg_sysconfdir ()); if (!result) - result = findkey_locale (key, locname, gnupg_datadir ()); + result = findkey_locale (key, locname, only_current_locale, + gnupg_datadir ()); return result; } diff --git a/common/i18n.c b/common/i18n.c index 3694947a9..c13be8608 100644 --- a/common/i18n.c +++ b/common/i18n.c @@ -45,7 +45,7 @@ i18n_init (void) /* The Assuan agent protocol requires us to transmit utf-8 strings - thus we need a fucntion to temporary switch gettext from native to + thus we need a fuctnion to temporary switch gettext from native to utf8. */ char * i18n_switchto_utf8 (void) diff --git a/common/t-helpfile.c b/common/t-helpfile.c index e4a1c2711..fa5d27a1c 100644 --- a/common/t-helpfile.c +++ b/common/t-helpfile.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include "util.h" +#include "i18n.h" /* #define pass() do { ; } while(0) */ /* #define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\ */ @@ -48,7 +49,7 @@ main (int argc, char **argv) argc--; argv++; } - result = gnupg_get_help_string (argc? argv[0]:NULL); + result = gnupg_get_help_string (argc? argv[0]:NULL, 0); if (!result) { fprintf (stderr, diff --git a/common/util.h b/common/util.h index cfc91e72b..e9d0ffbec 100644 --- a/common/util.h +++ b/common/util.h @@ -200,7 +200,7 @@ const char *gnupg_module_name (int which); void gnupg_rl_initialize (void); /*-- helpfile.c --*/ -char *gnupg_get_help_string (const char *key); +char *gnupg_get_help_string (const char *key, int only_current_locale); /*-- localename.c --*/ const char *gnupg_messages_locale_name (void); |