]>
git.ipfire.org Git - thirdparty/git.git/blob - gettext.h
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 void git_setup_gettext(void);
35 int gettext_width(const char *s
);
37 static inline void git_setup_gettext(void)
39 use_gettext_poison(); /* getenv() reentrancy paranoia */
41 static inline int gettext_width(const char *s
)
47 static inline FORMAT_PRESERVING(1) const char *_(const char *msgid
)
51 return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid
);
54 static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
55 const char *Q_(const char *msgid
, const char *plu
, unsigned long n
)
57 if (use_gettext_poison())
58 return "# GETTEXT POISON #";
59 return ngettext(msgid
, plu
, n
);
62 /* Mark msgid for translation but do not translate it. */
63 #if !USE_PARENS_AROUND_GETTEXT_N
64 #define N_(msgid) msgid
67 * Strictly speaking, this will lead to invalid C when
69 * static const char s[] = N_("FOO");
70 * which will expand to
71 * static const char s[] = ("FOO");
72 * and in valid C, the initializer on the right hand side must
73 * be without the parentheses. But many compilers do accept it
74 * as a language extension and it will allow us to catch mistakes
76 * static const char *msgs[] = {
82 * (notice the missing comma on one of the lines) by forcing
83 * a compilation error, because parenthesised ("one") ("two")
84 * will not get silently turned into ("onetwo").
86 #define N_(msgid) (msgid)
89 const char *get_preferred_languages(void);
90 int is_utf8_locale(void);