Fix compilation with NLS disabled

* src/utils.c: Only call setlocale() if NLS is enabled.
* src/calcurse.h: Define a fallback macro ngettext() if NLS is disabled.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-06-30 12:33:55 +02:00
parent 681a63ea76
commit 82d86ad7c7
2 changed files with 5 additions and 0 deletions

View File

@ -76,6 +76,7 @@
#define gettext(String) (String)
#define dgettext(String) (String)
#define dcgettext(String) (String)
#define ngettext(String1,String2,n) ((n) == 1 ? (String1) : (String2))
#define bindtextdomain(String) (String)
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
#endif /* ENABLE_NLS */

View File

@ -383,15 +383,19 @@ char *date_sec2date_str(long sec, const char *datefmt)
/* Generic function to format date. */
void date_sec2date_fmt(long sec, const char *fmt, char *datef)
{
#if ENABLE_NLS
/* TODO: Find a better way to deal with localization and strftime(). */
char *locale_old = mem_strdup (setlocale (LC_ALL, NULL));
setlocale (LC_ALL, "C");
#endif
struct tm *lt = localtime((time_t *)&sec);
strftime(datef, BUFSIZ, fmt, lt);
#if ENABLE_NLS
setlocale (LC_ALL, locale_old);
mem_free (locale_old);
#endif
}
/*