2 * Copyright (c) 2010-2011 Ævar Arnfjörð Bjarmason
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.
12 #if defined(_) || defined(Q_)
13 #error "namespace conflict: '_' or 'Q_' is pre-defined?"
22 # define gettext(s) (s)
26 # define ngettext(s, p, n) ((n == 1) ? (s) : (p))
29 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
31 int use_gettext_poison(void);
34 extern int git_gettext_enabled
;
35 void git_setup_gettext(void);
36 int gettext_width(const char *s
);
38 #define git_gettext_enabled (0)
39 static inline void git_setup_gettext(void)
41 use_gettext_poison(); /* getenv() reentrancy paranoia */
43 static inline int gettext_width(const char *s
)
49 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid
)
53 return use_gettext_poison() ? "# GETTEXT POISON #" :
54 !git_gettext_enabled
? msgid
: gettext(msgid
);
57 static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
58 const char *Q_(const char *msgid
, const char *plu
, unsigned long n
)
60 if (use_gettext_poison())
61 return "# GETTEXT POISON #";
62 if (!git_gettext_enabled
)
63 return n
== 1 ? msgid
: plu
;
64 return ngettext(msgid
, plu
, n
);
67 /* Mark msgid for translation but do not translate it. */
68 #if !USE_PARENS_AROUND_GETTEXT_N
69 #define N_(msgid) msgid
72 * Strictly speaking, this will lead to invalid C when
74 * static const char s[] = N_("FOO");
75 * which will expand to
76 * static const char s[] = ("FOO");
77 * and in valid C, the initializer on the right hand side must
78 * be without the parentheses. But many compilers do accept it
79 * as a language extension and it will allow us to catch mistakes
81 * static const char *msgs[] = {
87 * (notice the missing comma on one of the lines) by forcing
88 * a compilation error, because parenthesised ("one") ("two")
89 * will not get silently turned into ("onetwo").
91 #define N_(msgid) (msgid)
94 const char *get_preferred_languages(void);
95 int is_utf8_locale(void);