123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /**
- * \file locale.c
- *
- * \brief GIS Library - Functions to handle locale.
- *
- * (C) 2001-2008 by the GRASS Development Team
- *
- * This program is free software under the GNU General Public License
- * (>=v2). Read the file COPYING that comes with GRASS for details.
- *
- * \author GRASS GIS Development Team
- *
- * \date 2004-2008
- */
- #include <grass/config.h>
- #include <stdlib.h>
- #include <string.h>
- #include <locale.h>
- #include <grass/glocale.h>
- #include <grass/gis.h>
- #if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
- void G_init_locale(void)
- {
- static int initialized;
- char localedir[GPATH_MAX];
- const char *gisbase;
- if (initialized)
- return;
- initialized = 1;
- setlocale(LC_CTYPE, "");
- setlocale(LC_MESSAGES, "");
- gisbase = getenv("GISBASE");
- if (!gisbase || !*gisbase)
- return;
- strcpy(localedir, gisbase);
- strcat(localedir, "/locale");
- bindtextdomain("grasslibs", localedir);
- bindtextdomain("grassmods", localedir);
- }
- #endif
- /**
- * \brief Gets localized text.
- *
- * \param[in] package
- * \param[in] msgid
- * \retval char * Pointer to string
- */
- char *G_gettext(const char *package, const char *msgid)
- {
- #if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
- G_init_locale();
- return dgettext(package, msgid);
- #else
- return (char *)msgid;
- #endif
- }
|