src/session-child.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/session-child.c b/src/session-child.c index b6752f21..ec5638ef 100644 --- a/src/session-child.c +++ b/src/session-child.c @@ -240,6 +240,8 @@ audit_event (int type, const gchar *username, uid_t uid, const gchar *remote_hos } #endif +#define ALT_I18N_FILE "/etc/sysconfig/i18n" + static void apply_locale (const gchar *locale, GError **error) { @@ -274,12 +276,39 @@ apply_locale (const gchar *locale, GError **error) } static void -set_locale (const gchar *language, GError **error) +read_set_locale (const gchar *language, GError **error) { if (language && strlen (language) > 0) { apply_locale (language, error); + return; } + + g_autoptr(GFile) i18n = g_file_new_for_path (ALT_I18N_FILE); + g_autoptr(GFileInputStream) i18n_in = g_file_read (i18n, NULL, error); + + if (!i18n_in) + return; + + g_autoptr(GDataInputStream) i18n_din = g_data_input_stream_new (G_INPUT_STREAM (i18n_in)); + + const char *locale = NULL; + g_autofree char *ln = g_data_input_stream_read_line (i18n_din, NULL, NULL, error); + while (ln) + { + if (g_str_has_prefix (ln, "LANG=")) + { + locale = ln + 5; + break; + } + g_free (ln); + ln = g_data_input_stream_read_line (i18n_din, NULL, NULL, error); + } + + if (locale) + apply_locale (locale, error); + + g_input_stream_close (G_INPUT_STREAM (i18n_in), NULL, NULL); } int @@ -339,7 +368,7 @@ session_child_run (int argc, char **argv) g_autofree gchar *language = read_string (); g_autoptr(GError) locale_err = NULL; - set_locale (language, &locale_err); + read_set_locale (language, &locale_err); if (locale_err) { g_printerr ("Unable to read and set locale: %s", locale_err->message);