src: setlocale in main() for tools and the daemon

Previously, pw_init calls setlocale(), but this will change in future.
Setting the locale should be done by the main application, and is needed
in wireplumber for e.g. for translated UI elements.

Set the locale in main() for wireplumber daemon and tools, to have the
locale set also with the new pw_init behavior.

Set also LC_NUMERIC to C, to match old pw_init behavior.
This commit is contained in:
Pauli Virtanen 2022-03-22 20:51:02 +02:00 committed by George Kiagiadakis
parent f032ac00cf
commit 7e6e0e9ba0
3 changed files with 9 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <glib-unix.h>
#include <pipewire/pipewire.h>
#include <spa/utils/json.h>
#include <locale.h>
#define WP_DOMAIN_DAEMON (wp_domain_daemon_quark ())
static G_DEFINE_QUARK (wireplumber-daemon, wp_domain_daemon);
@ -402,6 +403,8 @@ main (gint argc, gchar **argv)
g_autoptr (WpProperties) properties = NULL;
g_autofree gchar *config_file_path = NULL;
setlocale (LC_ALL, "");
setlocale (LC_NUMERIC, "C");
wp_init (WP_INIT_ALL);
context = g_option_context_new ("- PipeWire Session/Policy Manager");

View file

@ -8,6 +8,7 @@
#include <wp/wp.h>
#include <stdio.h>
#include <locale.h>
#include <spa/utils/defs.h>
#include <pipewire/keys.h>
#include <pipewire/extensions/session-manager/keys.h>
@ -1114,6 +1115,8 @@ main (gint argc, gchar **argv)
g_autoptr (GError) error = NULL;
g_autofree gchar *summary = NULL;
setlocale (LC_ALL, "");
setlocale (LC_NUMERIC, "C");
wp_init (WP_INIT_ALL);
ctl.context = g_option_context_new (

View file

@ -10,6 +10,7 @@
#include <glib-unix.h>
#include <pipewire/keys.h>
#include <stdio.h>
#include <locale.h>
#define WP_DOMAIN_DAEMON (wp_domain_daemon_quark ())
static G_DEFINE_QUARK (wireplumber-daemon, wp_domain_daemon);
@ -219,6 +220,8 @@ main (gint argc, gchar **argv)
g_autoptr (GOptionContext) context = NULL;
g_autoptr (GError) error = NULL;
setlocale (LC_ALL, "");
setlocale (LC_NUMERIC, "C");
wp_init (WP_INIT_ALL);
context = g_option_context_new ("- WirePlumber script interpreter");