mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 14:54:14 +00:00
win32: Look up translations relative to installation directory
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@redhat.com>
This commit is contained in:
parent
55c4b04243
commit
afa5b45df8
@ -297,7 +297,22 @@ 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 *utf8_locale_dir = g_build_filename(base_path, "share", "locale", NULL);
|
||||
/* bindtextdomain's 2nd argument is not UTF-8 aware */
|
||||
gchar *locale_dir = g_win32_locale_filename_from_utf8 (utf8_locale_dir);
|
||||
|
||||
g_warn_if_fail(locale_dir != NULL);
|
||||
bindtextdomain(GETTEXT_PACKAGE, locale_dir);
|
||||
|
||||
g_free(base_path);
|
||||
g_free(utf8_locale_dir);
|
||||
g_free(locale_dir);
|
||||
#else
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
|
||||
#endif
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user