locale.c

Go to the documentation of this file.
00001 
00002 #include "config.h"
00003 #include "glocale.h"
00004 
00005 #include <stdlib.h>
00006 #include <string.h>
00007 #include <locale.h>
00008 
00009 static char *
00010 locale_dir(void)
00011 {
00012         static char localedir[4096];
00013 
00014         const char *gisbase;
00015 
00016         if (*localedir)
00017                 return localedir;
00018 
00019         gisbase = getenv("GISBASE");
00020         if (!gisbase || !*gisbase)
00021                 return "";
00022 
00023         strcpy(localedir, gisbase);
00024         strcat(localedir, "/locale");
00025 
00026         return localedir;
00027 }
00028 
00029 char *
00030 G_gettext(const char *package, const char *msgid)
00031 {
00032 #if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
00033         static char now_bound[4096];
00034         static int initialized;
00035 
00036         if (!initialized)
00037         {
00038                 setlocale(LC_CTYPE, "");
00039                 setlocale(LC_MESSAGES, "");
00040                 initialized = 1;
00041         }
00042 
00043         if (strcmp(now_bound, package) != 0)
00044         {
00045                 strcpy(now_bound, package);
00046                 bindtextdomain(package, locale_dir());
00047         }
00048 
00049         return dgettext(package, msgid);
00050 #else
00051         return (char *) msgid;
00052 #endif
00053 }
00054 

Generated on Mon Jan 1 19:49:25 2007 for GRASS by  doxygen 1.5.1