speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add i18n utilities to common library


From: William Hubbs
Subject: [PATCH] Add i18n utilities to common library
Date: Tue, 5 Oct 2010 10:43:46 -0500

I'll take this one.

The first thing I notice is that you are defining localedir in
configure.ac.  I don't think that is necessary.  I will look at it
though.

William

On Tue, Oct 05, 2010 at 03:45:59PM +0100, Rui Batista wrote:
> This patches adds internationalization support to the common library.
> the i18n_init function should be called before
> any gettext translation function usage.
> 
> The include/i18n.h contains the i18n_init declaration and includes the
> glib i18n headers for conveninece.
> ---
>  configure.ac           |    3 +++
>  include/Makefile.am    |    2 +-
>  include/i18n.h         |   34 ++++++++++++++++++++++++++++++++++
>  src/common/Makefile.am |    4 +++-
>  src/common/i18n.c      |   35 +++++++++++++++++++++++++++++++++++
>  5 files changed, 76 insertions(+), 2 deletions(-)
>  create mode 100644 include/i18n.h
>  create mode 100644 src/common/i18n.c
> 
> diff --git a/configure.ac b/configure.ac
> index a0c305d..cf513d4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -302,6 +302,9 @@ AC_SUBST([LIB_SPD_AGE])
>  GETTEXT_PACKAGE=speech-dispatcher
>  AC_SUBST([GETTEXT_PACKAGE])
>  
> +localedir='${datadir}/locale'
> +AC_SUBST([localedir])
> + 
>  # Paths for configuration files:
>  spdconfdir='${sysconfdir}/speech-dispatcher'
>  AC_SUBST([spdconfdir])
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 4597166..9bec647 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -1,4 +1,4 @@
>  ## Process this file with automake to produce Makefile.in
>  
> -noinst_HEADERS = fdsetconv.h speechd_types.h spd_utils.h
> +noinst_HEADERS = fdsetconv.h speechd_types.h spd_utils.h i18n.h
>  
> diff --git a/include/i18n.h b/include/i18n.h
> new file mode 100644
> index 0000000..43dbc9c
> --- /dev/null
> +++ b/include/i18n.h
> @@ -0,0 +1,34 @@
> +/*
> + * i18n.h - i18n support for Speech Dispatcher
> + *
> + * Copyright (C) 2010 Brailcom, o.p.s.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2, or (at your option)
> + * any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this package; see the file COPYING.  If not, write to
> + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> + * Boston, MA 02110-1301, USA.
> + *
> + */
> +
> +#ifndef I18N_H
> +#define I18N_H
> +#include <glib/gi18n.h>
> +
> +/*
> +* Inits i18n support for Speech Dispatcher components
> +* This function must be called before any component outputs messages
> +* that should be translated to the user.
> +*/
> +void init_i18n(void);
> +
> +#endif
> diff --git a/src/common/Makefile.am b/src/common/Makefile.am
> index 68c5766..8f25bc2 100644
> --- a/src/common/Makefile.am
> +++ b/src/common/Makefile.am
> @@ -1,7 +1,9 @@
>  ## Process this file with automake to produce Makefile.in
>  
>  noinst_LTLIBRARIES = libcommon.la
> -libcommon_la_CFLAGS = $(ERROR_CFLAGS)
> +libcommon_la_CFLAGS = $(ERROR_CFLAGS) $(GLIB_CFLAGS) \
> +-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" -DLOCALEDIR=\"$(localedir)\"
>  libcommon_la_CPPFLAGS = "-I$(top_srcdir)/include/" $(GLIB_CFLAGS)
>  libcommon_la_LIBADD = $(GLIB_LIBS)
>  libcommon_la_SOURCES = fdsetconv.c spd_getline.c
> +
> diff --git a/src/common/i18n.c b/src/common/i18n.c
> new file mode 100644
> index 0000000..006d915
> --- /dev/null
> +++ b/src/common/i18n.c
> @@ -0,0 +1,35 @@
> +/*
> + * i18n.c - i18n support for Speech-dispatcher
> + *
> + * Copyright (C) 2010 Brailcom, o.p.s.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2, or (at your option)
> + * any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this package; see the file COPYING.  If not, write to
> + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> + * Boston, MA 02110-1301, USA.
> + *
> + */
> +
> +#if HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#include <i18n.h>
> +#include <locale.h>          /* For setlocale. */
> +
> +void init_i18n(void)
> +{
> +     setlocale(LC_ALL, "");
> +     bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
> +     textdomain(GETTEXT_PACKAGE);
> +}
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> Speechd mailing list
> Speechd at lists.freebsoft.org
> http://lists.freebsoft.org/mailman/listinfo/speechd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: 
<http://lists.freebsoft.org/pipermail/speechd/attachments/20101005/2a778a9b/attachment.pgp>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]