[glib/glib.fixtools.i18n: 32/34] glib-private.h: Set the appropriate string for setlocale()



commit 3e5d1bd6ff5e52d4d5862dc001cec0fa6e2ae2f0
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jun 5 16:34:57 2019 +0800

    glib-private.h: Set the appropriate string for setlocale()
    
    On Windows, in particular the CRTs on and after Visual Studio 2012, it
    is not enough just to do setlocale (LC_ALL, "") to set the default
    system locale, which results in the tools that use the translated
    messages to show unreadable messages when running the commmand line
    tools.
    
    This adds an entry in glib-private.h.in which denotes the appropriate
    string to use for setlocale() to set the default system locale by
    setting it to ".ACP" if we are building on Windows and "" for
    other systems (as we are doing now).
    
    The tools in gio/ will be updated in the next commit to make use of this
    entry so that the translated messages can be shown correctly.

 glib/glib-private.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/glib/glib-private.h b/glib/glib-private.h
index d0099236f..8b7ab132e 100644
--- a/glib/glib-private.h
+++ b/glib/glib-private.h
@@ -84,4 +84,25 @@ typedef struct {
 GLIB_AVAILABLE_IN_ALL
 GLibPrivateVTable *glib__private__ (void);
 
+/* Please see following for the use of ".ACP" over ""
+ * on Windows, although both are accepted at compile-time
+ * but "" renders translated console messages unreadable if
+ * built with Visual Studio 2012 and later (this is, unfortunately,
+ * undocumented):
+ *
+ * https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale
+ * https://gitlab.gnome.org/GNOME/glib/merge_requests/895#note_525881
+ * https://gitlab.gnome.org/GNOME/glib/merge_requests/895#note_525900
+ *
+ * Additional related items:
+ * https://stackoverflow.com/questions/22604329/php-5-5-setlocale-not-working-in-cli-on-windows
+ * https://bugs.php.net/bug.php?id=66265
+ */
+
+#ifdef G_OS_WIN32
+# define GLIB_DEFAULT_LOCALE ".ACP"
+#else
+# define GLIB_DEFAULT_LOCALE ""
+#endif
+
 #endif /* __GLIB_PRIVATE_H__ */


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