diff options
author | Ales Kozumplik <akozumpl@redhat.com> | 2011-10-05 13:58:37 +0200 |
---|---|---|
committer | Ales Kozumplik <akozumpl@redhat.com> | 2011-10-10 13:04:55 +0200 |
commit | 152149133732a45a13f3c8ab728de767536a09ab (patch) | |
tree | d7902ef52800af0262b621517e02437b86f422b3 /loader/lang.c | |
parent | fd6085f6c5812373d4b1bdbefd6a10aa9eff2e61 (diff) | |
download | anaconda-152149133732a45a13f3c8ab728de767536a09ab.tar.gz anaconda-152149133732a45a13f3c8ab728de767536a09ab.tar.xz anaconda-152149133732a45a13f3c8ab728de767536a09ab.zip |
Handle strange lang boot argument values.
First, internally translate '.utf8' to '.UTF-8' so it matches the
lang-table.
Second, if a language missing from the lang-table is used with lang=,
fallback on en_US.
Resolves: rhbz#731356
Diffstat (limited to 'loader/lang.c')
-rw-r--r-- | loader/lang.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/loader/lang.c b/loader/lang.c index 6b1fa8e4f..a11de14f3 100644 --- a/loader/lang.c +++ b/loader/lang.c @@ -36,6 +36,7 @@ #include <sys/wait.h> #include <unistd.h> #include <wchar.h> +#include <glib.h> #include "loader.h" #include "lang.h" @@ -103,6 +104,14 @@ char * translateString(char * str) { static struct langInfo * languages = NULL; static int numLanguages = 0; +static int defaultLanguageIndex(void) { + int i; + for (i = 0; i < numLanguages; ++i) + if (!strcmp(languages[i].lc_all, LANG_DEFAULT)) + return i; + return -1; +} + static void loadLanguageList(void) { char * file = "/etc/lang-table"; FILE * f; @@ -144,6 +153,25 @@ int getLangInfo(struct langInfo ** langs) { return numLanguages; } +/** + * Normalize the value of lang= boot argument. + * + * Currently only replaces the trailing .utf8 with .UTF-8. + * + * Returns a heap-allocated string. + */ +gchar *normalizeLang(const gchar *s) +{ + if (g_str_has_suffix(s, ".utf8")) { + gchar *lang = g_strndup(s, strlen(s) - strlen(".utf8")); + gchar *result = g_strconcat(lang, ".UTF-8", NULL); + g_free(lang); + return result; + } + + return g_strdup(s); +} + void loadLanguage(void) { char *filename; @@ -395,8 +423,9 @@ int setLanguage (const char * key, int forced) { } } - logMessage(ERROR, "unable to set to requested language %s", key); - return -1; + logMessage(ERROR, "unable to set the requested language '%s', " + "setting the default '%s'", key, LANG_DEFAULT); + return setupLanguage(defaultLanguageIndex(), forced | !FL_KICKSTART(flags)); } int chooseLanguage(char ** lang) { |