translate.c 770 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "proto.h"
  4. #include <grass/glocale.h>
  5. /* Returns translated version of a string.
  6. If global variable to output strings for translation is set it spits them out */
  7. char *translate(const char *arg)
  8. {
  9. if (arg == NULL)
  10. return (char *) arg;
  11. if (strlen(arg) == 0)
  12. return NULL; /* unset */
  13. if (*arg && translate_output) {
  14. fputs(arg, stdout);
  15. fputs("\n", stdout);
  16. }
  17. #if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
  18. static const char *domain;
  19. if (!domain) {
  20. domain = getenv("GRASS_TRANSLATION_DOMAIN");
  21. if (domain)
  22. G_putenv("GRASS_TRANSLATION_DOMAIN", "grassmods");
  23. else
  24. domain = PACKAGE;
  25. }
  26. return G_gettext(domain, arg);
  27. #else
  28. return (char *) arg;
  29. #endif
  30. }