4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define _(msgid) gettext(msgid)
29 #define gettext_noop(msgid) msgid
30 #define N_(msgid) gettext_noop(msgid)
32 #define str_(s)_str(s)
34 // for contextual use:
35 // #define MSGQUAL qual_id
36 // C_: msgid decorated as: MSGQUAL#msg_id implicitly
37 // D_: msgid decorated as: qual_id#msg_id explicitly
38 // see po/xlat.sh for details
40 // qualifier from MSGQUAL
41 #define C_(msgid) msgqual(str_(MSGQUAL),msgid)
42 // qualifier from msgid
43 #define D_(msgid) msgtext(msgid)
45 static inline char *msgtext(const char *msgid)
47 char *msgstr = gettext(msgid);
48 if( msgstr == msgid ) {
49 for( char *cp=msgstr; *cp!=0; ) if( *cp++ == '#' ) return gettext(cp);
50 msgstr = (char*) msgid;
55 static inline char *msgqual(const char *msgqual,const char *msgid)
57 if( !msgqual || !*msgqual ) return gettext(msgid);
58 char msg[strlen(msgid) + strlen(msgqual) + 2], *cp = msg;
59 for( const char *bp=msgqual; *bp!=0; *cp++=*bp++ );
61 for( const char *bp=msgid; *bp!=0; *cp++=*bp++ );
63 if( (cp=gettext(msg)) == msg ) cp = gettext(msgid);