fix GNU gettext locale finding

This commit is contained in:
tildearrow 2024-06-15 23:59:25 -05:00
parent 928bf04e1f
commit a2a37745d8

View file

@ -48,6 +48,7 @@ struct sigaction termsa;
#define TUT_INTRO_PLAYED false
#endif
#ifdef HAVE_LOCALE
#ifdef HAVE_MOMO
#define TA_BINDTEXTDOMAIN momo_bindtextdomain
#define TA_TEXTDOMAIN momo_textdomain
@ -66,6 +67,7 @@ struct sigaction termsa;
#ifndef LC_MESSAGES
#define LC_MESSAGES 1
#endif
#endif
#include "cli/cli.h"
@ -109,6 +111,19 @@ bool infoMode=false;
std::vector<TAParam> params;
#ifdef HAVE_LOCALE
char localeDir[4096];
const char* localeDirs[]={
"locale",
"../po/locale",
#ifdef LOCALE_DIR
LOCALE_DIR,
#endif
NULL
};
#endif
TAParamResult pHelp(String) {
printf("usage: furnace [params] [filename]\n"
"you may specify the following parameters:\n");
@ -546,27 +561,27 @@ int main(int argc, char** argv) {
}
#endif
if ((localeRet=TA_BINDTEXTDOMAIN("furnace","locale"))==NULL) {
if ((localeRet=TA_BINDTEXTDOMAIN("furnace","../po/locale"))==NULL) {
#ifdef LOCALE_DIR
if ((localeRet=TA_BINDTEXTDOMAIN("furnace",LOCALE_DIR))==NULL) {
logE("could not bind text domain!");
} else {
logV("text domain 1: %s",localeRet);
}
#else
logE("could not bind text domain!");
#endif
bool textDomainBound=false;
for (int i=0; localeDirs[i]; i++) {
strncpy(localeDir,localeDirs[i],4095);
logV("bind text domain: %s",localeDir);
if (!dirExists(localeDir)) continue;
if ((localeRet=TA_BINDTEXTDOMAIN("furnace",localeDir))==NULL) {
continue;
} else {
textDomainBound=true;
logV("text domain 1: %s",localeRet);
break;
}
} else {
logV("text domain 1: %s",localeRet);
}
if ((localeRet=TA_TEXTDOMAIN("furnace"))==NULL) {
logE("could not text domain!");
if (!textDomainBound) {
logE("could not bind text domain!");
} else {
logV("text domain 2: %s",localeRet);
if ((localeRet=TA_TEXTDOMAIN("furnace"))==NULL) {
logE("could not text domain!");
} else {
logV("text domain 2: %s",localeRet);
}
}
#endif