[Spice-devel] [spice-gtk v2] Initialise gettext library properly

Marc-André Lureau mlureau at redhat.com
Thu Aug 18 21:37:40 UTC 2016


Hi

----- Original Message -----
> This will allow internationalisation to work correctly.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/Makefile.am           |  3 +++
>  src/channel-usbredir.c    |  2 +-
>  src/desktop-integration.c |  2 +-
>  src/spice-channel.c       |  2 +-
>  src/spice-cmdline.c       |  2 +-
>  src/spice-glib-main.c     | 52
>  +++++++++++++++++++++++++++++++++++++++++++++++
>  src/spice-option.c        |  2 +-
>  src/usb-device-manager.c  |  2 +-
>  src/usb-device-widget.c   |  2 +-
>  src/usbutil.c             |  2 +-
>  10 files changed, 63 insertions(+), 8 deletions(-)
>  create mode 100644 src/spice-glib-main.c
> 
> Changes since v1:
> - changed include from glib/gi18n.h to glib/gi18n-lib.h
>   make it work! Thanks Jonathon to spot the issue!
> 
> On Linux work very well.
> Didn't manage to make it work on Windows... not sure what's the
> problem :(
> I switched the entire system to Italian but all Remote Viewer
> remains in English.

That's fine for me as a first step if nobody want to bother with windows now, so ack
 
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index fc84e30..53987dd 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -104,6 +104,7 @@ SPICE_COMMON_CPPFLAGS =						\
>  	$(NULL)
>  
>  AM_CPPFLAGS =					\
> +	-DLOCALE_DIR=\""$(datadir)/locale"\"	\
>  	$(SPICE_COMMON_CPPFLAGS)		\
>  	$(SPICE_CFLAGS)				\
>  	$(NULL)
> @@ -276,6 +277,8 @@ libspice_client_glib_2_0_la_SOURCES =			\
>  							\
>  	client_sw_canvas.c	\
>  	client_sw_canvas.h	\
> +							\
> +	spice-glib-main.c				\
>  	$(NULL)
>  
>  nodist_libspice_client_glib_2_0_la_SOURCES =	\
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index 0e7a0b0..dd17e6c 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -22,7 +22,7 @@
>  #include "config.h"
>  
>  #ifdef USE_USBREDIR
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  #include <usbredirhost.h>
>  #ifdef USE_LZ4
>  #include <lz4.h>
> diff --git a/src/desktop-integration.c b/src/desktop-integration.c
> index 529fb05..8070a71 100644
> --- a/src/desktop-integration.c
> +++ b/src/desktop-integration.c
> @@ -26,7 +26,7 @@
>  #include "spice-session-priv.h"
>  #include "desktop-integration.h"
>  
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  
>  #define GNOME_SESSION_INHIBIT_AUTOMOUNT 16
>  
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 0eb0e61..4e792a2 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -25,7 +25,7 @@
>  #include "spice-marshal.h"
>  #include "bio-gio.h"
>  
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  
>  #include <openssl/rsa.h>
>  #include <openssl/evp.h>
> diff --git a/src/spice-cmdline.c b/src/spice-cmdline.c
> index 8619b57..4b6f4c2 100644
> --- a/src/spice-cmdline.c
> +++ b/src/spice-cmdline.c
> @@ -16,7 +16,7 @@
>     License along with this library; if not, see
>     <http://www.gnu.org/licenses/>.
>  */
>  #include "config.h"
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  
>  #include "spice-client.h"
>  #include "spice-common.h"
> diff --git a/src/spice-glib-main.c b/src/spice-glib-main.c
> new file mode 100644
> index 0000000..c2bd7ca
> --- /dev/null
> +++ b/src/spice-glib-main.c
> @@ -0,0 +1,52 @@
> +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> +/*
> +   Copyright (C) 2016 Red Hat, Inc.
> +
> +   This library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   This library 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
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with this library; if not, see
> <http://www.gnu.org/licenses/>.
> +*/
> +#include "config.h"
> +
> +#include <glib.h>
> +#include <glib/gi18n-lib.h>
> +#include <common/macros.h>
> +
> +#ifdef G_OS_WIN32
> +#define WIN32_LEAN_AND_MEAN
> +#include <windows.h>
> +
> +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
> lpvReserved);
> +
> +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
> lpvReserved)
> +{
> +    if (fdwReason == DLL_PROCESS_ATTACH) {
> +        char *basedir =
> +            g_win32_get_package_installation_directory_of_module(hinstDLL);
> +        char *localedir = g_build_filename(basedir, "share", "locale",
> NULL);
> +        bindtextdomain(GETTEXT_PACKAGE, localedir);
> +        g_free(localedir);
> +        g_free(basedir);
> +        bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
> +    }
> +    return TRUE;
> +}
> +
> +#else
> +
> +SPICE_CONSTRUCTOR_FUNC(i18n_init)
> +{
> +    bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
> +    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
> +}
> +
> +#endif
> diff --git a/src/spice-option.c b/src/spice-option.c
> index 4d5aab2..c04e978 100644
> --- a/src/spice-option.c
> +++ b/src/spice-option.c
> @@ -19,7 +19,7 @@
>  
>  #include <stdlib.h>
>  #include <glib-object.h>
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  #include "spice-session.h"
>  #include "spice-util.h"
>  #include "spice-channel-priv.h"
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 53505fa..4f956fd 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -51,7 +51,7 @@
>  #include "spice-marshal.h"
>  #include "usb-device-manager-priv.h"
>  
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  
>  #ifndef G_OS_WIN32 /* Linux -- device id is bus.addr */
>  #define DEV_ID_FMT "at %u.%u"
> diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
> index 05c7054..b394499 100644
> --- a/src/usb-device-widget.c
> +++ b/src/usb-device-widget.c
> @@ -20,7 +20,7 @@
>  */
>  
>  #include "config.h"
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  #include "spice-client.h"
>  #include "spice-marshal.h"
>  #include "usb-device-widget.h"
> diff --git a/src/usbutil.c b/src/usbutil.c
> index 6dcb4de..7bfbe44 100644
> --- a/src/usbutil.c
> +++ b/src/usbutil.c
> @@ -22,7 +22,7 @@
>  #include "config.h"
>  
>  #include <glib-object.h>
> -#include <glib/gi18n.h>
> +#include <glib/gi18n-lib.h>
>  #include <ctype.h>
>  #include <stdlib.h>
>  
> --
> 2.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list