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:
parent
681a63ea76
commit
82d86ad7c7
@ -76,6 +76,7 @@
|
|||||||
#define gettext(String) (String)
|
#define gettext(String) (String)
|
||||||
#define dgettext(String) (String)
|
#define dgettext(String) (String)
|
||||||
#define dcgettext(String) (String)
|
#define dcgettext(String) (String)
|
||||||
|
#define ngettext(String1,String2,n) ((n) == 1 ? (String1) : (String2))
|
||||||
#define bindtextdomain(String) (String)
|
#define bindtextdomain(String) (String)
|
||||||
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
|
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
|
||||||
#endif /* ENABLE_NLS */
|
#endif /* ENABLE_NLS */
|
||||||
|
@ -383,15 +383,19 @@ char *date_sec2date_str(long sec, const char *datefmt)
|
|||||||
/* Generic function to format date. */
|
/* Generic function to format date. */
|
||||||
void date_sec2date_fmt(long sec, const char *fmt, char *datef)
|
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(). */
|
/* TODO: Find a better way to deal with localization and strftime(). */
|
||||||
char *locale_old = mem_strdup (setlocale (LC_ALL, NULL));
|
char *locale_old = mem_strdup (setlocale (LC_ALL, NULL));
|
||||||
setlocale (LC_ALL, "C");
|
setlocale (LC_ALL, "C");
|
||||||
|
#endif
|
||||||
|
|
||||||
struct tm *lt = localtime((time_t *)&sec);
|
struct tm *lt = localtime((time_t *)&sec);
|
||||||
strftime(datef, BUFSIZ, fmt, lt);
|
strftime(datef, BUFSIZ, fmt, lt);
|
||||||
|
|
||||||
|
#if ENABLE_NLS
|
||||||
setlocale (LC_ALL, locale_old);
|
setlocale (LC_ALL, locale_old);
|
||||||
mem_free (locale_old);
|
mem_free (locale_old);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user