Commit 4d102692 authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

Now GDM will recognize when the system language has changed and when new

2006-12-29  Brian Cameron  <brian.cameron@sun.com>

        * configure.ac, daemon/Makefile.am, daemon/misc.[ch],
          daemon/slave.c, daemon/verify-pam.c:  Now GDM will recognize
          when the system language has changed and when new GUI's are
          displayed they will be in the new system language without
          neeting to restart GDM.  By default the /var/sysconfig/i18n
          file is assumed to have the language defined in LANG=foo format.
          The --with-lang-file configure option may be needed to specify
          a different system language configuration file.  On Solaris
          it would be /etc/default/init, for example.  Note the change
          to verify-pam is done to flush the hash table of pam messages
          to useful translations.  This change implements enhancement
          request #384603.  Patch by Ray Strode <rstrode@redhat.com>
          and Takao Fujiwara <Takao.Fujiwara@sun.com>.
parent 9bfc7c4a
2006-12-29 Brian Cameron <brian.cameron@sun.com>
* configure.ac, daemon/Makefile.am, daemon/misc.[ch],
daemon/slave.c, daemon/verify-pam.c: Now GDM will recognize
when the system language has changed and when new GUI's are
displayed they will be in the new system language without
neeting to restart GDM. By default the /var/sysconfig/i18n
file is assumed to have the language defined in LANG=foo format.
The --with-lang-file configure option may be needed to specify
a different system language configuration file. On Solaris
it would be /etc/default/init, for example. Note the change
to verify-pam is done to flush the hash table of pam messages
to useful translations. This change implements enhancement
request #384603. Patch by Ray Strode <rstrode@redhat.com>
and Takao Fujiwara <Takao.Fujiwara@sun.com>.
2006-12-21 Lukasz Zalewski <lukas@dcs.qmul.ac.uk>
* More fixes/changes for bug/feature request #334186.
......
......@@ -116,6 +116,21 @@ else
fi
AC_SUBST(PAM_PREFIX)
dnl
dnl file that sets LANG
dnl
withval=""
AC_ARG_WITH(lang-file,
[ --with-lang-file=<filename> file containing default language setting],[
if test x$withval != x; then
AC_MSG_RESULT("System locale will be looked for in file ${withval}.")
fi])
if test x$withval != x; then
LANG_CONFIG_FILE="$withval"
else
LANG_CONFIG_FILE='${sysconfdir}/sysconfig/i18n'
fi
AC_SUBST(LANG_CONFIG_FILE)
AC_PATH_PROG(CONSOLE_HELPER,consolehelper,no)
if test "x$CONSOLE_HELPER" = "xno" ; then
......
......@@ -24,6 +24,7 @@ INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
$(GUI_CFLAGS) \
$(DAEMON_CFLAGS) \
-DLANG_CONFIG_FILE=\"$(LANG_CONFIG_FILE)\" \
-DPAM_PREFIX=\"$(PAM_PREFIX)\" \
$(GNOME_INCLUDEDIR) \
-DGREETERTHEMEDIR=\""$(datadir)/gdm/themes"\"
......
......@@ -2145,6 +2145,90 @@ gdm_reset_limits (void)
}
}
#define CHECK_LC(value, category) \
(g_str_has_prefix (line->str, value "=")) \
{ \
character = g_utf8_get_char (line->str + strlen (value "=")); \
\
if ((character == '\'') || (character == '\"')) \
{ \
q = g_utf8_find_prev_char (line->str, line->str + line->len); \
\
if ((q == NULL) || (g_utf8_get_char (q) != character)) \
{ \
g_string_set_size (line, 0); \
continue; \
} \
\
g_string_set_size (line, line->len - 1); \
g_setenv (value, line->str + strlen (value "=") + 1, TRUE); \
if (category) \
setlocale ((category), line->str + strlen (value "=") + 1); \
} \
else \
{ \
g_setenv (value, line->str + strlen (value "="), TRUE); \
if (category) \
setlocale ((category), line->str + strlen (value "=")); \
} \
\
g_string_set_size (line, 0); \
continue; \
}
void
gdm_reset_locale (void)
{
char *i18n_file_contents;
gsize i18n_file_length, i;
GString *line;
const gchar *p, *q;
i18n_file_contents = NULL;
line = NULL;
p = NULL;
if (!g_file_get_contents (LANG_CONFIG_FILE, &i18n_file_contents,
&i18n_file_length, NULL))
goto out;
if (!g_utf8_validate (i18n_file_contents, i18n_file_length, NULL))
goto out;
line = g_string_new ("");
p = i18n_file_contents;
for (i = 0; i < i18n_file_length;
p = g_utf8_next_char (p), i = p - i18n_file_contents)
{
gunichar character;
character = g_utf8_get_char (p);
if ((character != '\n') && (character != '\0'))
{
g_string_append_unichar (line, character);
continue;
}
if CHECK_LC("LC_ALL", LC_ALL)
else if CHECK_LC("LC_COLLATE", LC_COLLATE)
else if CHECK_LC("LC_MESSAGES", LC_MESSAGES)
else if CHECK_LC("LC_MONETARY", LC_MONETARY)
else if CHECK_LC("LC_NUMERIC", LC_NUMERIC)
else if CHECK_LC("LC_TIME", LC_TIME)
else if CHECK_LC("LANG", NULL)
g_string_set_size (line, 0);
}
g_string_free (line, TRUE);
setlocale (LC_ALL, "");
out:
g_free (i18n_file_contents);
}
#undef CHECK_LC(value, category)
#else /* ! NUM_OF_LIMITS */
/* We have to go one by one here */
......
......@@ -142,6 +142,7 @@ FILE * gdm_safe_fopen_ap (const char *file);
limits */
void gdm_get_initial_limits (void);
void gdm_reset_limits (void);
void gdm_reset_locale (void);
const char *gdm_root_user (void);
......
......@@ -1309,6 +1309,8 @@ gdm_slave_run (GdmDisplay *display)
gint maxtries = 0;
gint pinginterval = gdm_get_value_int (GDM_KEY_PING_INTERVAL);
gdm_reset_locale ();
/* Reset d since gdm_slave_run is called in a loop */
d = display;
......@@ -1758,6 +1760,7 @@ run_config (GdmDisplay *display, struct passwd *pwent)
/* setup environment */
gdm_restoreenv ();
gdm_reset_locale ();
/* root here */
g_setenv ("XAUTHORITY", GDM_AUTHFILE (display), TRUE);
......@@ -2519,6 +2522,7 @@ gdm_slave_greeter (void)
"gdm_slave_greeter", gdm_get_gdmuid ());
gdm_restoreenv ();
gdm_reset_locale ();
g_setenv ("XAUTHORITY", GDM_AUTHFILE (d), TRUE);
g_setenv ("DISPLAY", d->name, TRUE);
......@@ -3020,6 +3024,7 @@ gdm_slave_chooser (void)
"gdm_slave_chooser", gdm_get_gdmuid ());
gdm_restoreenv ();
gdm_reset_locale ();
g_setenv ("XAUTHORITY", GDM_AUTHFILE (d), TRUE);
g_setenv ("DISPLAY", d->name, TRUE);
......
......@@ -417,7 +417,21 @@ perhaps_translate_message (const char *msg)
char *s;
const char *ret;
static GHashTable *hash = NULL;
static char *locale = NULL;
/* if locale changes out from under us then rebuild hash table
*/
if ((locale != NULL) &&
(strcmp (locale, setlocale (LC_ALL, NULL)) != 0)) {
g_assert (hash != NULL);
g_hash_table_destroy (hash);
hash = NULL;
}
if (hash == NULL) {
g_free (locale);
locale = g_strdup (setlocale (LC_ALL, NULL));
/* Here we come with some fairly standard messages so that
we have as much as possible translated. Should really be
translated in pam I suppose. This way we can "change"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment