rework intl strategy, titler upgrades, fonts fixes, igor ru.po
[goodguy/history.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
32 // for contextual use:
33 //  #undef MSGQUAL
34 //  #define MSGQUAL "qual_id"
35 // C_: msgid decorated as: MSGQUAL#msg_id implicitly
36 // D_: msgid decorated as: qual_id#msg_id explicitly
37 // see po/xlat.sh for details
38
39 #define MSGQUAL 0
40 // qualifier from MSGQUAL
41 #define C_(msgid) ((MSGQUAL)? msgqual(MSGQUAL,msgid) : gettext(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 cp;
50     msgstr = (char*) msgid;
51   }
52   return msgstr;
53 }
54
55 static inline char *msgqual(const char *msgqual,const char *msgid)
56 {
57   char msg[strlen(msgid) + strlen(msgqual) + 2], *cp = msg;
58   for( const char *bp=msgqual; *bp!=0; *cp++=*bp++ );
59   *cp++ = '#';
60   for( const char *bp=msgid; *bp!=0; *cp++=*bp++ );
61   *cp = 0;
62   if( (cp=gettext(msg)) == msg ) cp = (char*)msgid;
63   return cp;
64 }
65
66 #endif