summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-07-28 12:09:14 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-28 14:23:11 +0800
commit2a44f3c936f948d6fedc4729dbf2216da558e490 (patch)
tree6b225bea0cf0969c5fa1767c19aa7fe7f1d7d499 /discover/device-handler.c
parent9330aba60a05a8d9889dab42bc92b9ebbc55941b (diff)
downloadtalos-petitboot-2a44f3c936f948d6fedc4729dbf2216da558e490.tar.gz
talos-petitboot-2a44f3c936f948d6fedc4729dbf2216da558e490.zip
discover: Add setlocale calls in discover server
We want the discover server to respect the configured language, so we'll need to add appropriate setlocale() calls. We use the config->lang setting to use any previously-saved language. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 22866e6..e7990e7 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -16,6 +16,7 @@
#include <system/system.h>
#include <process/process.h>
#include <url/url.h>
+#include <i18n/i18n.h>
#include "device-handler.h"
#include "discover-server.h"
@@ -59,6 +60,8 @@ static int umount_device(struct discover_device *dev);
static int device_handler_init_sources(struct device_handler *handler);
static void device_handler_reinit_sources(struct device_handler *handler);
+static void device_handler_update_lang(const char *lang);
+
void discover_context_add_boot_option(struct discover_context *ctx,
struct discover_boot_option *boot_option)
{
@@ -824,11 +827,26 @@ void device_handler_update_config(struct device_handler *handler,
return;
discover_server_notify_config(handler->server, config);
+ device_handler_update_lang(config->lang);
device_handler_reinit(handler);
}
#ifndef PETITBOOT_TEST
+static void device_handler_update_lang(const char *lang)
+{
+ const char *cur_lang;
+
+ if (!lang)
+ return;
+
+ cur_lang = setlocale(LC_ALL, NULL);
+ if (cur_lang && !strcmp(cur_lang, lang))
+ return;
+
+ setlocale(LC_ALL, lang);
+}
+
static int device_handler_init_sources(struct device_handler *handler)
{
/* init our device sources: udev, network and user events */
@@ -1025,6 +1043,10 @@ void device_release_write(struct discover_device *dev, bool release)
#else
+static void device_handler_update_lang(const char *lang __attribute__((unused)))
+{
+}
+
static int device_handler_init_sources(
struct device_handler *handler __attribute__((unused)))
{
OpenPOWER on IntegriCloud