Re: [virt-viewer] win32: Look up translations relative to installation directory

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

 



On Fri, Apr 20, 2018 at 12:36:18PM +0200, Christophe Fergeau wrote:
> On Windows, we can't use bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); as
> LOCALE_DIR is a compile-time constant, while the location of the
> translations will be dependant on where the user installs virt-viewer.
> This results in an untranslated virt-viewer UI on Windows. This commit
> calls bindtextdomain() with a directory which is relative to the
> installation path so that translation are properly found.
> This is similar to what spice-gtk is doing:
> https://cgit.freedesktop.org/spice/spice-gtk/tree/src/spice-glib-main.c
> 
> Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>
> ---
>  src/virt-viewer-util.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> index 226c9fa..e9ee4eb 100644
> --- a/src/virt-viewer-util.c
> +++ b/src/virt-viewer-util.c
> @@ -297,7 +297,18 @@ void virt_viewer_util_init(const char *appname)
>  #endif
>  
>      setlocale(LC_ALL, "");
> +
> +#ifdef G_OS_WIN32
> +    gchar *base_path = g_win32_get_package_installation_directory_of_module(NULL);
> +    gchar *locale_dir = g_build_filename(base_path, "share", "locale", NULL);
> +    g_free(base_path);

If I look in gtk/gtkwin32.c it has an extra step


      /* gtk_localedir is passed to bindtextdomain() which isn't
       * UTF-8-aware.
       */
      gtk_localedir = g_win32_locale_filename_from_utf8 (temp);


> +
> +    bindtextdomain(GETTEXT_PACKAGE, locale_dir);
> +
> +    g_free(locale_dir);
> +#else
>      bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
> +#endif
>      bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
>      textdomain(GETTEXT_PACKAGE);

And hmm, we'll need to fix this bug in gtk-vnc too, and in libvirt-glib
and in libvirt.

Wouldn't be surprised if most other deps of libvirt are broken too as
pretty much everyone just uses LOCALE_DIR for bindtextdomain() :-(


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux