X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Flanguage.h;h=ae5f9803d1319f29e13d3866753d00165667fcdb;hb=d60a59baa6cfe24c0fb153ed9e150a834ba29feb;hp=ba0f4c97e4975de6de9aec9225f5ae53fc1657bd;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/language.h b/cinelerra-5.1/guicast/language.h index ba0f4c97..ae5f9803 100644 --- a/cinelerra-5.1/guicast/language.h +++ b/cinelerra-5.1/guicast/language.h @@ -2,42 +2,66 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #ifndef LANGUAGE_H #define LANGUAGE_H - - #include - - -#define _(String) gettext(String) -#define gettext_noop(String) String -#define N_(String) gettext_noop (String) - - +#include + +#define _(msgid) gettext(msgid) +#define gettext_noop(msgid) msgid +#define N_(msgid) gettext_noop(msgid) +#define _str(i)#i +#define str_(s)_str(s) + +// for contextual use: +// #define MSGQUAL qual_id +// C_: msgid decorated as: MSGQUAL#msg_id implicitly +// D_: msgid decorated as: qual_id#msg_id explicitly +// see po/xlat.sh for details +// +// qualifier from MSGQUAL +#define C_(msgid) msgqual(str_(MSGQUAL),msgid) +// qualifier from msgid +#define D_(msgid) msgtext(msgid) + +static inline char *msgtext(const char *msgid) +{ + char *msgstr = gettext(msgid); + if( msgstr == msgid ) { + for( char *cp=msgstr; *cp!=0; ) if( *cp++ == '#' ) return gettext(cp); + msgstr = (char*) msgid; + } + return msgstr; +} + +static inline char *msgqual(const char *msgqual,const char *msgid) +{ + if( !msgqual || !*msgqual ) return gettext(msgid); + char msg[strlen(msgid) + strlen(msgqual) + 2], *cp = msg; + for( const char *bp=msgqual; *bp!=0; *cp++=*bp++ ); + *cp++ = '#'; + for( const char *bp=msgid; *bp!=0; *cp++=*bp++ ); + *cp = 0; + if( (cp=gettext(msg)) == msg ) cp = gettext(msgid); + return cp; +} #endif - - - - - - -