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*/
89
#ifndef GETTEXT_H
10#define GETTEXT_H
1112
#if defined(_) || defined(Q_)
13#error "namespace conflict: '_' or 'Q_' is pre-defined?"
14#endif
1516
#ifndef NO_GETTEXT
17# include <libintl.h>
18#else
19# ifdef gettext
20# undef gettext
21# endif
22# define gettext(s) (s)
23# ifdef ngettext
24# undef ngettext
25# endif
26# define ngettext(s, p, n) ((n == 1) ? (s) : (p))
27#endif
2829
#define FORMAT_PRESERVING(n) __attribute__((format_arg(n)))
3031
#ifndef NO_GETTEXT
32extern void git_setup_gettext(void);
33#else
34static inline void git_setup_gettext(void)
35{
36}
37#endif
3839
#ifdef GETTEXT_POISON
40extern int use_gettext_poison(void);
41#else
42#define use_gettext_poison() 0
43#endif
4445
static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)
46{
47return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid);
48}
4950
static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)
51const char *Q_(const char *msgid, const char *plu, unsigned long n)
52{
53if (use_gettext_poison())
54return "# GETTEXT POISON #";
55return ngettext(msgid, plu, n);
56}
5758
/* Mark msgid for translation but do not translate it. */
59#define N_(msgid) msgid
6061
#endif