xref: /freebsd/contrib/xz/src/common/tuklib_gettext.h (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       tuklib_gettext.h
4 /// \brief      Wrapper for gettext and friends
5 //
6 //  Author:     Lasse Collin
7 //
8 //  This file has been put into the public domain.
9 //  You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12 
13 #ifndef TUKLIB_GETTEXT_H
14 #define TUKLIB_GETTEXT_H
15 
16 #include "tuklib_common.h"
17 #include <locale.h>
18 
19 #ifndef TUKLIB_GETTEXT
20 #	ifdef ENABLE_NLS
21 #		define TUKLIB_GETTEXT 1
22 #	else
23 #		define TUKLIB_GETTEXT 0
24 #	endif
25 #endif
26 
27 #if TUKLIB_GETTEXT
28 #	include <libintl.h>
29 #	define tuklib_gettext_init(package, localedir) \
30 		do { \
31 			setlocale(LC_ALL, ""); \
32 			bindtextdomain(package, localedir); \
33 			textdomain(package); \
34 		} while (0)
35 #	define _(msgid) gettext(msgid)
36 #else
37 #	define tuklib_gettext_init(package, localedir) \
38 		setlocale(LC_ALL, "")
39 #	define _(msgid) (msgid)
40 #	define ngettext(msgid1, msgid2, n) ((n) == 1 ? (msgid1) : (msgid2))
41 #endif
42 #define N_(msgid) msgid
43 
44 #endif
45