[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 20/40] gtk: use setlocale() for LC_MESSAGES only
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 20/40] gtk: use setlocale() for LC_MESSAGES only |
Date: |
Wed, 21 Oct 2015 12:51:50 -0500 |
From: Alberto Garcia <address@hidden>
The QEMU code is not internationalized and assumes that it runs under
the C locale, but if we use the GTK+ UI we'll end up importing the
locale settings from the environment. This can break things, such as
the JSON generator and iotest 120 in locales that use a decimal comma.
We do however have translations for a few simple strings for the GTK+
menu items, so in order to run QEMU using the C locale, and yet have a
translated UI let's use setlocale() for LC_MESSAGES only.
Cc: address@hidden
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
(cherry picked from commit 2cb5d2a47c655331bcf0ab16bab8fe4701182c58)
Signed-off-by: Michael Roth <address@hidden>
---
ui/gtk.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index df2a79e..11ea2cf 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1941,7 +1941,8 @@ void gtk_display_init(DisplayState *ds, bool full_screen,
bool grab_on_hover)
s->free_scale = FALSE;
- setlocale(LC_ALL, "");
+ /* LC_MESSAGES only. See early_gtk_display_init() for details */
+ setlocale(LC_MESSAGES, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
@@ -2010,6 +2011,24 @@ void gtk_display_init(DisplayState *ds, bool
full_screen, bool grab_on_hover)
void early_gtk_display_init(int opengl)
{
+ /* The QEMU code relies on the assumption that it's always run in
+ * the C locale. Therefore it is not prepared to deal with
+ * operations that produce different results depending on the
+ * locale, such as printf's formatting of decimal numbers, and
+ * possibly others.
+ *
+ * Since GTK+ calls setlocale() by default -importing the locale
+ * settings from the environment- we must prevent it from doing so
+ * using gtk_disable_setlocale().
+ *
+ * QEMU's GTK+ UI, however, _does_ have translations for some of
+ * the menu items. As a trade-off between a functionally correct
+ * QEMU and a fully internationalized UI we support importing
+ * LC_MESSAGES from the environment (see the setlocale() call
+ * earlier in this file). This allows us to display translated
+ * messages leaving everything else untouched.
+ */
+ gtk_disable_setlocale();
gtkinit = gtk_init_check(NULL, NULL);
if (!gtkinit) {
/* don't exit yet, that'll break -help */
--
1.9.1
- [Qemu-devel] [PATCH 00/40] Patch Round-up for stable 2.4.1, freeze on 2015-10-29, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 11/40] PPC: E500: Update u-boot to commit 79c884d7e4, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 12/40] s390x/css: start with cleared cstat/dstat, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 16/40] virtio dataplane: adapt dataplane for virtio Version 1, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 15/40] cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 17/40] target-arm: Share all common TCG temporaries, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 13/40] rtl8139: Fix receive buffer overflow check, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 14/40] rtl8139: Do not consume the packet during overflow in standard mode., Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 20/40] gtk: use setlocale() for LC_MESSAGES only,
Michael Roth <=
- [Qemu-devel] [PATCH 01/40] scsi-disk: Fix assertion failure on WRITE SAME, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 21/40] spapr_pci: fix device tree props for MSI/MSI-X, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 18/40] qcow2: Make size_to_clusters() return uint64_t, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 23/40] slirp: Fix non blocking connect for w32, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 19/40] ide: fix ATAPI command permissions, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 22/40] nbd: release exp->blk after all clients are closed, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 24/40] ide: unify io_buffer_offset increments, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 25/40] qom: Do not reuse errp after a possible error, Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 26/40] qom: Fix invalid error check in property_get_str(), Michael Roth, 2015/10/21
- [Qemu-devel] [PATCH 27/40] tcg/mips: Fix clobbering of qemu_ld inputs, Michael Roth, 2015/10/21