Bug#136312: boot-floppies: Support list of languages to use like glibc LANGUAGE varialbe
[Phil Blundell]
> Right, yeah, that's what I thought. So that code looks to me like
> it will print the error message if any catalog loading is
> successful, rather than if they all fail. Surely that's exactly the
> opposite of what's wanted?
Right. Fixed in the current version.
Here is a new patch, relative to the current CVS version. This
version do not reorganize the code, and should be easier to check.
Index: boxes.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/boxes.c,v
retrieving revision 1.67
diff -u -3 -p -u -r1.67 boxes.c
--- boxes.c 2002/03/10 17:55:44 1.67
+++ boxes.c 2002/03/15 20:46:19
@@ -1181,10 +1181,23 @@ boxChooseLanguageVariant (const struct l
struct language_item *li = list[i].list->items[0].p;
if (list[i].list->items[0].d != 1)
continue;
- sprintf(prtbuf, "/etc/messages.%s", li->msgcat);
- if (access(prtbuf, R_OK))
- continue;
-
+ /* If any of the languages listed in the colon separated
+ list of language codes is available, accept it */
+ {
+ int accessable = 0;
+ char *languagelist = strdup(li->msgcat);
+ char *language = NULL;
+ for ( language = strtok(languagelist, ":");
+ language && *language; language = strtok(NULL, ":") )
+ {
+ sprintf(prtbuf, "/etc/messages.%s", language);
+ if (0 == access(prtbuf, R_OK))
+ ++accessable;
+ }
+ free(languagelist);
+ if (! accessable)
+ continue;
+ }
wpadit (tempo, list[i].hint, width);
newtListboxAddEntry (lang_list, tempo, list + i);
}
Index: main.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/main.c,v
retrieving revision 1.147
diff -u -3 -p -u -r1.147 main.c
--- main.c 2002/03/12 02:39:00 1.147
+++ main.c 2002/03/15 20:46:19
@@ -799,20 +799,33 @@ int main (void) {
const struct language_definition *langs = available_languages ();
if (locale && strstr(locale, "utf-8")) {
+ int translation_available = 0;
/* UTF-8 mode, choose a language */
do {
lang = boxChooseLanguageVariant (langs);
} while (lang == NULL);
- snprintf (msgcat, PATH_MAX, "/etc/messages.%s", lang->msgcat);
- msgcat[PATH_MAX - 1] = '\0';
- DEBUGMSG ("loading message catalog %s", msgcat);
-
- if (LOAD_TRMFILE (msgcat) == 0) /* Failed to load localized strings? */
+
{
- if (LOAD_TRMFILE (TRMBACKUP) == 0) /* Failed to load English strings as well? */
- {
+ char *languagelist = strdup(lang->msgcat);
+ char *language = NULL;
+ for ( language = strtok(languagelist, ":");
+ ! translation_available && language && *language;
+ language = strtok(NULL, ":") )
+ {
+ snprintf (msgcat, PATH_MAX, "/etc/messages.%s", language);
+ msgcat[PATH_MAX - 1] = '\0';
+ DEBUGMSG ("trying to load message catalog %s", msgcat);
+
+ if (LOAD_TRMFILE (msgcat) != 0)
+ translation_available = 1;
+ }
+ free(languagelist);
+ }
+ if ( ! translation_available &&
+ LOAD_TRMFILE (TRMBACKUP) == 0) /* Failed to load English strings as well? */
+ {
problemBoxEn ("An error occured while loading application messages.", "Problem");
-
+
reboot (RB_AUTOBOOT);
/* when not root and debugging */
@@ -828,7 +841,6 @@ int main (void) {
problemBoxEn (message, "Problem");
}
- }
} else {
/* Try to force the language to English */
while (langs->name != NULL && strcmp(langs->name, "English"))
Index: release_notes.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/release_notes.c,v
retrieving revision 1.10
diff -u -3 -p -u -r1.10 release_notes.c
--- release_notes.c 2002/03/13 15:59:44 1.10
+++ release_notes.c 2002/03/15 20:46:19
@@ -52,12 +52,23 @@ release_notes (const char *suffix)
char *fname = (char *)malloc (PATH_MAX);
if (fname)
{
- snprintf (fname, PATH_MAX, RELEASE_FILE_FMT, suffix);
- if (display_notes(fname) == 0)
+ char *languagelist = strdup(suffix);
+ char *language = NULL;
+ /* If any of the languages listed in the colon separated
+ list of language codes is available, accept it */
+ for ( language = strtok(languagelist, ":");
+ language && *language;
+ language = strtok(NULL, ":") )
{
- free (fname);
- return 0;
+ snprintf (fname, PATH_MAX, RELEASE_FILE_FMT, language);
+ if (display_notes(fname) == 0)
+ {
+ free (languagelist);
+ free (fname);
+ return 0;
+ }
}
+ free (languagelist);
free(fname);
}
}
Index: util.c
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/util.c,v
retrieving revision 1.80
diff -u -3 -p -u -r1.80 util.c
--- util.c 2002/03/14 12:02:16 1.80
+++ util.c 2002/03/15 20:46:20
@@ -1219,7 +1219,17 @@ otherway:
/* okay, no country matching, trying the another mapping */
i=0;
while(mirror_country_map[i] != NULL) {
- if(strcmp(lang->msgcat,mirror_country_map[i]) == 0) {
+ char *languagelist = strdup(lang->msgcat);
+ char *language = NULL;
+ int match = 0;
+ for ( language = strtok(languagelist, ":");
+ language && *language;
+ language = strtok(NULL, ":") ) {
+ if(strcmp(language,mirror_country_map[i]) == 0)
+ match = 1;
+ }
+ free(languagelist);
+ if (match) {
sprintf(hostname, "ftp.%s.debian.org", mirror_country_map[i+1]);
return;
}
Index: langs/norwegian.src
===================================================================
RCS file: /cvs/debian-boot/boot-floppies/utilities/dbootstrap/langs/norwegian.src,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 norwegian.src
--- langs/norwegian.src 2001/10/17 03:30:12 1.1
+++ langs/norwegian.src 2002/03/15 20:46:20
@@ -3,10 +3,10 @@
<hint>no - Du har valgt norsk. Trykk Enter for å fortsette</hint>
<list>
<name>Velg språkvariant</name>
- <item arch="i386" locale="no_NO.ISO-8859-1" acm="iso01" font="LatArCyrHeb-16" keymap="i386/qwerty/no-latin1" msgcat="nb">
+ <item arch="i386" locale="no_NO.ISO-8859-1" acm="iso01" font="LatArCyrHeb-16" keymap="i386/qwerty/no-latin1" msgcat="nb_NO:nb:no_NO:no:nn_NO:nn:dk:sv">
<name>Bokmål</name>
</item>
- <item arch="i386" locale="nn_NO.ISO-8859-1" acm="iso01" font="LatArCyrHeb-16" keymap="i386/qwerty/no-latin1" msgcat="nn">
+ <item arch="i386" locale="nn_NO.ISO-8859-1" acm="iso01" font="LatArCyrHeb-16" keymap="i386/qwerty/no-latin1" msgcat="nn_NO:nn:nb_NO:nb:no_NO:no:dk:sv">
<name>Nynorsk</name>
</item>
</list>
Reply to: