diff options
-rw-r--r-- | Makefile.am | 9 | ||||
-rw-r--r-- | acinclude.m4 | 47 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | xload.c | 14 |
4 files changed, 87 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index c80096d..1063365 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,3 +85,12 @@ ChangeLog: $(CHANGELOG_CMD) dist-hook: ChangeLog INSTALL + +if USE_GETTEXT +noinst_DATA = xload.po + +xload.po: $(xload_SOURCES:%=$(srcdir)/%) + $(AM_V_GEN)xgettext -d xload -n $(xload_SOURCES:%=$(srcdir)/%) + +CLEANFILES += xload.po +endif diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..8e80584 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,47 @@ +# =========================================================================== +# http://www.nongnu.org/autoconf-archive/ax_define_dir.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION]) +# +# DESCRIPTION +# +# This macro sets VARNAME to the expansion of the DIR variable, taking +# care of fixing up ${prefix} and such. +# +# VARNAME is then offered as both an output variable and a C preprocessor +# symbol. +# +# Example: +# +# AX_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.]) +# +# LICENSE +# +# Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz> +# Copyright (c) 2008 Andreas Schwab <schwab@suse.de> +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# Copyright (c) 2008 Alexandre Oliva +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +AU_ALIAS([AC_DEFINE_DIR], [AX_DEFINE_DIR]) +AC_DEFUN([AX_DEFINE_DIR], [ + prefix_NONE= + exec_prefix_NONE= + test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix + test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix +dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn +dnl refers to ${prefix}. Thus we have to use `eval' twice. + eval ax_define_dir="\"[$]$2\"" + eval ax_define_dir="\"$ax_define_dir\"" + AC_SUBST($1, "$ax_define_dir") + AC_DEFINE_UNQUOTED($1, "$ax_define_dir", [$3]) + test "$prefix_NONE" && prefix=NONE + test "$exec_prefix_NONE" && exec_prefix=NONE +]) diff --git a/configure.ac b/configure.ac index 77482c6..5deb5d3 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,26 @@ AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL +# Internationalization & localization support +AC_SEARCH_LIBS([gettext], [intl], [USE_GETTEXT="yes"], [USE_GETTEXT="no"]) +AC_MSG_CHECKING([where to install localized messages]) +AC_ARG_WITH([localedir], AS_HELP_STRING([--with-localedir=<path>], + [Path to install message files in (default: datadir/locale)]), + [LOCALEDIR=${withval}], [LOCALEDIR=${datadir}/locale]) +AX_DEFINE_DIR([LOCALEDIR], [LOCALEDIR], [Location of translated messages]) +if test "x$LOCALEDIR" = "xno" -o "x$USE_GETTEXT" = "xno" ; then + AC_MSG_RESULT([nowhere]) + USE_GETTEXT="no" +else + AC_MSG_RESULT([$LOCALEDIR]) +fi + +if test "x$USE_GETTEXT" = "xyes" ; then + AC_DEFINE([USE_GETTEXT], 1, + [Define to 1 if you want to use the gettext() function.]) +fi +AM_CONDITIONAL(USE_GETTEXT, test "x$USE_GETTEXT" = "xyes") + ### How to check load average on various OS'es: @@ -57,6 +57,10 @@ from the X Consortium. * xload - display system load average in a window */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -73,8 +77,12 @@ from the X Consortium. #include <X11/Xmu/SysUtil.h> #include "xload.h" -#include <libintl.h> -#include <X11/Xlocale.h> +#ifdef USE_GETTEXT +# include <X11/Xlocale.h> +# include <libintl.h> +#else +# define gettext(a) (a) +#endif #include "xload.bit" @@ -202,7 +210,7 @@ main(int argc, char **argv) textdomain("xload"); if ((domaindir = getenv ( "TEXTDOMAINDIR" )) == NULL) { - domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/ + domaindir = LOCALEDIR; } bindtextdomain("xload", domaindir); |