diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2011-11-05 10:24:42 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2011-11-05 10:24:42 +0100 |
commit | cc8367f974cc1c3b8d8f301c7916231135414d63 (patch) | |
tree | 3f64e9f32f7d9803fb162f6bc8862d55b6648acb /include/wolf/i18n | |
parent | 7bf0ff7b79608d91f47dbe1519f783307dddf307 (diff) | |
download | wolfbones-cc8367f974cc1c3b8d8f301c7916231135414d63.tar.gz wolfbones-cc8367f974cc1c3b8d8f301c7916231135414d63.tar.bz2 |
gettext is in i18n now, has nothing to do with porting
Diffstat (limited to 'include/wolf/i18n')
-rw-r--r-- | include/wolf/i18n/gettext.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/include/wolf/i18n/gettext.h b/include/wolf/i18n/gettext.h new file mode 100644 index 0000000..3d4a4f9 --- /dev/null +++ b/include/wolf/i18n/gettext.h @@ -0,0 +1,93 @@ +/* + Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef WOLF_GETTEXT_H +#define WOLF_GETTEXT_H + +/** + * @addtogroup wolf_port Porting + * @{ + */ + +/** + * @file gettext.h + * @brief localization header, nivelating some problems in gettext/libintl + * @author Andreas Baumann <abaumann@yahoo.com> + */ + +/* some distributors like to disable NLS */ +#if ENABLE_NLS + +/* Some older versions of libintl.h make tests for the value __APPLE_CC though + * this macro can be undefined! Nice, defining it here as 0. + * (Noticed on OpenBSD 4.3) + */ +#if !defined( __APPLE_CC ) +#define __APPLE_CC__ 0 +#endif + +/* define a proper prototype with format_arg so that gcc doesn't croak. This + * is a problem on systems which have an onlder libintl.h where the declarations + * are missing. So we define a first prototype here and hope the compiler survives + * the redefiniton in libintl.h but for a format_arg (urgh!). Experienced only + * on NetBSD 4.1 + */ +#if defined __GNUC__ +#if defined GETTEXT_NEEDS_FORMAT_ARG +char *gettext( const char *__msgid ) __attribute__ ( ( format_arg ( 1 ) ) ); +char *libintl_gettext( const char *__msgid ) __attribute__ ( ( format_arg ( 1 ) ) ); +char *dgettext( const char *__domainname, const char *__msgid ) __attribute__ ( ( format_arg ( 2 ) ) ); +char *libintl_dgettext( const char *__domainname, const char *__msgid ) __attribute__ ( ( format_arg ( 2 ) ) ); +#endif +#endif + +#include <libintl.h> /* for gettext, bindtextdomain */ + +#include <locale.h> /* for setlocale */ + +/** It's much easier to define a DEFAULT_TEXT_DOMAIN and map gettext to a + * dgettext, so that we don't have to call 'textdomain' anywhere in the + * library. Define this before including gettext.h + */ +#if defined DEFAULT_TEXT_DOMAIN +#undef gettext +#define gettext( msgid ) dgettext( DEFAULT_TEXT_DOMAIN, msgid ) +#endif /* defined DEFAULT_TEXT_DOMAIN */ + +#else /* ENABLE_NLS */ + +#define gettext( msgid ) ( (const char *)( msgid ) ) +#define LC_ALL 1 +#define setlocale( category, loc ) ( NULL ) +#define bindtextdomain( domain, directory ) ( NULL ) +#define textdomain( domain )( NULL ) + +#endif /* ENABLE_NLS */ + +/* a noop marker which let's xgettext extract the message but doesn't + * call the gettext() function if NLS is enabled. + */ +#define gettext_noop( s ) s + +/* shorthand macro for lazy people */ +#define _( s ) gettext( s ) + +void wolf_port_initialize_i18n( const char *argv0, const char *app ); + +/** @} */ /* @addtogroup wolf_port */ + +#endif /* ifndef WOLF_GETTEXT_H */ |