THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.2KB

  1. /*
  2. * Copyright (c) 2010-2011 Ævar Arnfjörð Bjarmason
  3. *
  4. * This is a skeleton no-op implementation of gettext for Git.
  5. * You can replace it with something that uses libintl.h and wraps
  6. * gettext() to try out the translations.
  7. */
  8. #ifndef GETTEXT_H
  9. #define GETTEXT_H
  10. #if defined(_) || defined(Q_)
  11. #error "namespace conflict: '_' or 'Q_' is pre-defined?"
  12. #endif
  13. #ifndef NO_GETTEXT
  14. # include <libintl.h>
  15. #else
  16. # ifdef gettext
  17. # undef gettext
  18. # endif
  19. # define gettext(s) (s)
  20. # ifdef ngettext
  21. # undef ngettext
  22. # endif
  23. # define ngettext(s, p, n) ((n == 1) ? (s) : (p))
  24. #endif
  25. #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
  26. int use_gettext_poison(void);
  27. #ifndef NO_GETTEXT
  28. void git_setup_gettext(void);
  29. int gettext_width(const char *s);
  30. #else
  31. static inline void git_setup_gettext(void)
  32. {
  33. use_gettext_poison(); /* getenv() reentrancy paranoia */
  34. }
  35. static inline int gettext_width(const char *s)
  36. {
  37. return strlen(s);
  38. }
  39. #endif
  40. static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
  41. {
  42. if (!*msgid)
  43. return "";
  44. return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid);
  45. }
  46. static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
  47. const char *Q_(const char *msgid, const char *plu, unsigned long n)
  48. {
  49. if (use_gettext_poison())
  50. return "# GETTEXT POISON #";
  51. return ngettext(msgid, plu, n);
  52. }
  53. /* Mark msgid for translation but do not translate it. */
  54. #if !USE_PARENS_AROUND_GETTEXT_N
  55. #define N_(msgid) msgid
  56. #else
  57. /*
  58. * Strictly speaking, this will lead to invalid C when
  59. * used this way:
  60. * static const char s[] = N_("FOO");
  61. * which will expand to
  62. * static const char s[] = ("FOO");
  63. * and in valid C, the initializer on the right hand side must
  64. * be without the parentheses. But many compilers do accept it
  65. * as a language extension and it will allow us to catch mistakes
  66. * like:
  67. * static const char *msgs[] = {
  68. * N_("one")
  69. * N_("two"),
  70. * N_("three"),
  71. * NULL
  72. * };
  73. * (notice the missing comma on one of the lines) by forcing
  74. * a compilation error, because parenthesised ("one") ("two")
  75. * will not get silently turned into ("onetwo").
  76. */
  77. #define N_(msgid) (msgid)
  78. #endif
  79. const char *get_preferred_languages(void);
  80. int is_utf8_locale(void);
  81. #endif