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 9 #ifndef GETTEXT_H 10 #define GETTEXT_H 11 12 #if defined(_) || defined(Q_) 13 #error "namespace conflict: '_' or 'Q_' is pre-defined?" 14 #endif 15 16 #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 28 29 #define FORMAT_PRESERVING(n) __attribute__((format_arg(n))) 30 31 #ifndef NO_GETTEXT 32 void git_setup_gettext(void); 33 int gettext_width(const char *s); 34 #else git_setup_gettext(void)35static inline void git_setup_gettext(void) 36 { 37 } gettext_width(const char * s)38static inline int gettext_width(const char *s) 39 { 40 return strlen(s); 41 } 42 #endif 43 _(const char * msgid)44static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) 45 { 46 if (!*msgid) 47 return ""; 48 return gettext(msgid); 49 } 50 51 static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2) Q_(const char * msgid,const char * plu,unsigned long n)52const char *Q_(const char *msgid, const char *plu, unsigned long n) 53 { 54 return ngettext(msgid, plu, n); 55 } 56 57 /* Mark msgid for translation but do not translate it. */ 58 #define N_(msgid) msgid 59 60 const char *get_preferred_languages(void); 61 int is_utf8_locale(void); 62 63 #endif 64