dl-fldigi/src/misc/nls.cxx

40 wiersze
840 B
C++
Czysty Zwykły widok Historia

2009-05-26 18:57:44 +00:00
#include <config.h>
#include <locale.h>
#include <cstdlib>
#include <unistd.h>
#include <sys/stat.h>
#include "gettext.h"
int setup_nls(void)
{
static int nls_set_up = 0;
if (nls_set_up)
return nls_set_up;
setlocale (LC_MESSAGES, "");
setlocale (LC_CTYPE, "C");
setlocale (LC_TIME, "");
// setting LC_NUMERIC might break the config read/write routines
const char* ldir;
char buf[4096];
if (!(ldir = getenv("FLDIGI_LOCALE_DIR"))) {
if (getcwd(buf, sizeof(buf) - strlen("/locale") - 1)) {
strcpy(buf + strlen(buf), "/locale");
struct stat s;
if (stat(buf, &s) != -1 && S_ISDIR(s.st_mode))
ldir = buf;
else
ldir = LOCALEDIR;
}
}
bindtextdomain(PACKAGE, ldir);
/* fltk-1.1.x only knows about Latin-1 */
bind_textdomain_codeset(PACKAGE, "ISO-8859-1");
textdomain(PACKAGE);
return nls_set_up = 1;
}