diff options
Diffstat (limited to '')
-rw-r--r-- | common/simple-gettext.c (renamed from util/simple-gettext.c) | 87 |
1 files changed, 29 insertions, 58 deletions
diff --git a/util/simple-gettext.c b/common/simple-gettext.c index 3249775bf..56a305fd8 100644 --- a/util/simple-gettext.c +++ b/common/simple-gettext.c @@ -1,6 +1,5 @@ /* simple-gettext.c - a simplified version of gettext. - * Copyright (C) 1995, 1996, 1997, 1999, - * 2005 Free Software Foundation, Inc. + * Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -40,9 +39,9 @@ #include <errno.h> #include <sys/types.h> #include <sys/stat.h> -#include "types.h" -#include "util.h" +#include "util.h" +#include "sysutils.h" /* The magic number of the GNU message catalog format. */ #define MAGIC 0x950412de @@ -233,14 +232,13 @@ load_domain( const char *filename ) /**************** - * Set the file used for translations. Pass a NULL to disable - * translation. A new filename may be set at anytime. If REGKEY is - * not NULL, the function tries to selected the language the registry - * key "Lang" below that key. WARNING: After changing the filename you - * should not access any data retrieved by gettext(). + * Set the file used for translations. Pass a NULL to disable + * translation. A new filename may be set at anytime. + * WARNING: After changing the filename you should not access any data + * retrieved by gettext(). */ int -set_gettext_file ( const char *filename, const char *regkey ) +set_gettext_file( const char *filename ) { struct loaded_domain *domain = NULL; @@ -255,57 +253,30 @@ set_gettext_file ( const char *filename, const char *regkey ) /* absolute path - use it as is */ domain = load_domain( filename ); } - else if (regkey) { /* Standard. */ - char *instdir, *langid, *fname; + else { /* relative path - append ".mo" and get dir from the environment */ + char *buf = NULL; + char *dir; char *p; - instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", - regkey, - "Install Directory"); - if (!instdir) - return -1; - langid = read_w32_registry_string (NULL, /* HKCU then HKLM */ - regkey, - "Lang"); - if (!langid) { - free (instdir); - return -1; - } - /* Strip stuff after a dot in case the user tried to enter - * the entire locale synatcs as usual for POSIX. */ - p = strchr (langid, '.'); - if (p) - *p = 0; - - /* Build the key: "<instdir>/<domain>.nls/<langid>.mo" We - use a directory below the installation directory with - the domain included in case the software has been - insalled with other software altogether at the same - place. */ - fname = malloc (strlen (instdir) + 1 + strlen (filename) + 5 - + strlen (langid) + 3 + 1); - if (!fname) { - free (instdir); - free (langid); - return -1; - } - strcpy (stpcpy (stpcpy (stpcpy (stpcpy ( stpcpy (fname, - instdir),"\\"), filename), ".nls\\"), langid), ".mo"); - free (instdir); - free (langid); - - /* Better make sure that we don't mix forward and - backward slashes. It seems that some Windoze - versions don't accept this. */ - for (p=fname; *p; p++) { - if (*p == '/') - *p = '\\'; - } - domain = load_domain (fname); - free(fname); + dir = read_w32_registry_string( NULL, + "Control Panel\\Mingw32\\NLS", + "MODir" ); + if( dir && (buf=malloc(strlen(dir)+strlen(filename)+1+3+1)) ) { + strcpy(stpcpy(stpcpy(stpcpy( buf, dir),"\\"), filename),".mo"); + /* Better make sure that we don't mix forward and + backward slashes. It seems that some Windoze + versions don't accept this. */ + for (p=buf; *p; p++) + { + if (*p == '/') + *p = '\\'; + } + domain = load_domain( buf ); + free(buf); + } + free(dir); } - - if (!domain) + if( !domain ) return -1; } |