gettext.hpp

Go to the documentation of this file.
00001 /* $Id: gettext.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef GETTEXT_HPP_INCLUDED
00017 #define GETTEXT_HPP_INCLUDED
00018 
00019 /**
00020  * How to use gettext for wesnoth source files:
00021  * -# include this header file in the .cpp file
00022  * -# make sure, that the source file is listed in the respective POTFILES.in
00023  *    for the textdomain, in the case of wesnoth-lib it is this file:
00024  *    po/wesnoth-lib/POTFILES.in
00025  * -# add the following include to set the correct textdomain, in this example
00026  *    wesnoth-lib (not required for the domain 'wesnoth', required for all
00027  *    other textdomains).
00028  *    @code
00029  *    #define GETTEXT_DOMAIN "wesnoth-lib"
00030  *    @endcode
00031  *
00032  * This should be all that is required to have your strings that are marked
00033  * translatable in the po files and translated ingame. So you at least have
00034  * to mark the strings translatable, too. ;)
00035  */
00036 
00037 // gettext-related declarations
00038 
00039 #include <libintl.h>
00040 
00041 #ifdef setlocale
00042 // Someone in libintl world decided it was a good idea to define a "setlocale" macro.
00043 #undef setlocale
00044 #endif
00045 
00046 const char* egettext(const char*);
00047 const char* sgettext(const char*);
00048 const char* dsgettext(const char * domainname, const char *msgid);
00049 const char* sngettext(const char *singular, const char *plural, int n);
00050 const char* dsngettext(const char * domainname, const char *singular, const char *plural, int n);
00051 
00052 //A Hack to make the eclipse-cdt parser happy.
00053 #ifdef __CDT_PARSER__
00054 #define GETTEXT_DOMAIN ""
00055 #endif
00056 
00057 #ifdef GETTEXT_DOMAIN
00058 # define _(String) dsgettext(GETTEXT_DOMAIN,String)
00059 # define _n(String1,String2,Int) dsngettext(String1,String2,Int)
00060 # ifdef gettext
00061 #  undef gettext
00062 # endif
00063 # define gettext(String) dgettext(GETTEXT_DOMAIN,String)
00064 # define sgettext(String) dsgettext(GETTEXT_DOMAIN,String)
00065 # define sngettext(String1,String2,Int) dsngettext(GETTEXT_DOMAIN,String1,String2,Int)
00066 #else
00067 # define _(String) sgettext(String)
00068 # define _n(String1,String2,Int) sngettext(String1,String2,Int)
00069 #endif
00070 
00071 #define gettext_noop(String) String
00072 #define N_(String) gettext_noop (String)
00073 
00074 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:53 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs