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.
 
 
 
 
 
 

95 lines
2.2 KiB

  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. #ifndef NO_GETTEXT
  27. extern void git_setup_gettext(void);
  28. extern int gettext_width(const char *s);
  29. #else
  30. static inline void git_setup_gettext(void)
  31. {
  32. }
  33. static inline int gettext_width(const char *s)
  34. {
  35. return strlen(s);
  36. }
  37. #endif
  38. #ifdef GETTEXT_POISON
  39. extern int use_gettext_poison(void);
  40. #else
  41. #define use_gettext_poison() 0
  42. #endif
  43. static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
  44. {
  45. if (!*msgid)
  46. return "";
  47. return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid);
  48. }
  49. static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
  50. const char *Q_(const char *msgid, const char *plu, unsigned long n)
  51. {
  52. if (use_gettext_poison())
  53. return "# GETTEXT POISON #";
  54. return ngettext(msgid, plu, n);
  55. }
  56. /* Mark msgid for translation but do not translate it. */
  57. #if !USE_PARENS_AROUND_GETTEXT_N
  58. #define N_(msgid) msgid
  59. #else
  60. /*
  61. * Strictly speaking, this will lead to invalid C when
  62. * used this way:
  63. * static const char s[] = N_("FOO");
  64. * which will expand to
  65. * static const char s[] = ("FOO");
  66. * and in valid C, the initializer on the right hand side must
  67. * be without the parentheses. But many compilers do accept it
  68. * as a language extension and it will allow us to catch mistakes
  69. * like:
  70. * static const char *msgs[] = {
  71. * N_("one")
  72. * N_("two"),
  73. * N_("three"),
  74. * NULL
  75. * };
  76. * (notice the missing comma on one of the lines) by forcing
  77. * a compilation error, because parenthesised ("one") ("two")
  78. * will not get silently turned into ("onetwo").
  79. */
  80. #define N_(msgid) (msgid)
  81. #endif
  82. const char *get_preferred_languages(void);
  83. #endif