shuttlerc, boobytraps, vwindow hang, lock cleanup
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / language.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef LANGUAGE_H
23 #define LANGUAGE_H
24
25 #include <libintl.h>
26 #include <string.h>
27
28 #define _(msgid) gettext(msgid)
29 #define gettext_noop(msgid) msgid
30 #define N_(msgid) gettext_noop(msgid)
31 #define _str(i)#i
32 #define str_(s)_str(s)
33
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
39 //
40 // qualifier from MSGQUAL
41 #define C_(msgid) msgqual(str_(MSGQUAL),msgid)
42 // qualifier from msgid
43 #define D_(msgid) msgtext(msgid)
44
45 static inline char *msgtext(const char *msgid)
46 {
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;
51   }
52   return msgstr;
53 }
54
55 static inline char *msgqual(const char *msgqual,const char *msgid)
56 {
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++ );
60   *cp++ = '#';
61   for( const char *bp=msgid; *bp!=0; *cp++=*bp++ );
62   *cp = 0;
63   if( (cp=gettext(msg)) == msg ) cp = gettext(msgid);
64   return cp;
65 }
66
67 #endif