* Christian Perrier [2004-08-30 08:23:46+0200] > Quoting Recai Oktas ([EMAIL PROTECTED]): > > * Håvard Korsvoll [2004-08-29 12:19:41+0200] > > > I have tried a installation in norwegian bokmaal on a i386 system. > > > Started installation in export mode and looked around in different > > > menus to check translation. I changed the language back and forth > > > (nynorsk, english, bokmaal). Finally settled for bokmaal. Finished the > > > first stage and rebooted. > > > When booting in to the installed system I get english as language. > > > > > > When doing an install and choosing language one time only, it gets > > > right, I get norwegian bokmaal as language > > > > Hmm, this is probably the same bug as #265085? If so, we should merge > > them. > > You're certainly right. > > Recai, can you have a look at these bugs. They are quite nasty and, > I'm afraid, unanticipated consequences of the > languagechooser/countrychooser interaction. > > The best is probably by forcing countrychooser again after a > languagechooser run. However, I don't know how this could be > achieved....hence putting Joey in CC.....
I have prepared a patch set for {contry,language}chooser explained as follows: + countrychooser: * debian/postinst: - Move the core code to a separate executable as 'countrychooser'. - Make it a wrapper to /usr/bin/countrychooser. * debian/rules: Install countrychooser to /usr/bin. * debian/dirs: New file. * countrychooser: New file. The functionality in postinst can be reached easily. + languagechooser: * Add a workaround to support language reselections. (Closes: #265085, #268815) I've tested them here and seems fine to me. Christian, could you also give it a try? As I stated in the code (FIXME comment) I couldn't manage to find a better solution, maybe Joey suggests a more legal solution for the problem. One final note: Since the user changes the language, could it be reasonable to ask him/her for keyboard also? If you think so, here is the code portion which I've got successful results, (but I don't like the idea): db_set debconf/priority critical countrychooser + + # While on it, the user may also want to change keymap. + db_reset console-tools/arch + db_set debconf/priority high + kbd-chooser db_set debconf/priority $save_priority ) || true Regards, -- roktas
diff -ruN countrychooser.orig/countrychooser countrychooser/countrychooser --- countrychooser.orig/countrychooser 1970-01-01 02:00:00.000000000 +0200 +++ countrychooser/countrychooser 2004-08-17 23:49:49.000000000 +0300 @@ -0,0 +1,286 @@ +#!/bin/sh +set -e + +. /usr/share/debconf/confmodule + +db_capb backup + +INDENT=" " + +localecode="debian-installer/locale" +fallbacklocalecode="debian-installer/fallbacklocale" +languagechooserlocalecode="languagechooser/locale" +languagecode="debian-installer/language" +countrycode="debian-installer/country" +languagechooserlanguage="languagechooser/language-name" +shortlist="countrychooser/country-name-shortlist" +fulllist="countrychooser/country-name" + +# This is the iso_3166.tab file location +ISO3166TAB=/usr/share/iso-codes/iso_3166.tab +SUPPORTEDLOCALES=/etc/SUPPORTED-short +SHORTLISTS=/etc/shortlists + +for list in $ISO3166TAB ; do + if [ -f "$list" ]; then + countries="$list" + fi +done + +error() { + logger -t countrychooser "error: $@" + exit 1 +} + +log() { + logger -t countrychooser "info: $@" +} + +code2country() { + COUNTRYCODE="$1" + line=`grep "$COUNTRYCODE" $countries` + + if [ -n "$line" ]; then + # Remember that country names may have spaces so the code + # is different than in country2code. + printf "$INDENT" + echo $line | cut -b 4- + else + error "Unable to locate info on country '$COUNTRYCODE'" + fi +} + +country2code() { + COUNTRYNAME=$(echo "$1" | sed "s/^$INDENT//" | sed 's/\\,/,/g') + line=`grep "$COUNTRYNAME$" $countries` + + if [ -n "$line" ]; then + set $line + if [ -n "$1" ]; then + echo "$1" + fi + fi +} + +cat_shortlist() { + (out="" + IFS=' +' + while read line; do + if $(echo "$line" | grep -q "^:$1\$"); then + out=1 + elif $(echo "$line" | grep -q "^:"); then + out="" + elif [ "$out" ]; then + echo "$line" + fi + done + ) < $SHORTLISTS +} + +loccountry2code() { + COUNTRYNAME=$(echo "$1" | sed "s/^$INDENT//" | sed 's/\\,/,/g') + line=`cat_shortlist $2| grep "$COUNTRYNAME\$"` + if [ -n "$line" ]; then + set $line + if [ -n "$1" ]; then + echo "$1" + fi + fi +} + +# First grab back the country we got from languagechooser +# (or from elsewhere) and populate the debconf database with +# it so that it becomes the default choice +db_get "$countrycode" +if [ -n "$RET" ]; then + # Remember which code was first used + # This is needed at the end of the script + COUNTRYCODE_LANGUAGECHOOSER="$RET" + COUNTRY_LANGUAGECHOOSER="$(code2country "$RET")" + db_set "$fulllist" "${COUNTRY_LANGUAGECHOOSER}" + db_set "$shortlist" "${COUNTRY_LANGUAGECHOOSER}" +fi + + +# Then grab back the language we got from languagechooser +db_get "$languagechooserlanguage" +if [ -n "$RET" ]; then + LANGNAME="$RET" + # languagemap is a script from languagechooser which + # returns the language list in LANGUAGELIST and the + # language alone in LANGUAGE + if ! . languagemap ; then + LANGUAGE=C + else + # We need to remember these for further use + LOCALE_LANGUAGECHOOSER=$LOCALE + LANGUAGECODE_LANGUAGECHOOSER=$LANGUAGE + fi +fi + +# Then grab back the locale we got from languagechooser +db_get "$localecode" +if [ -n "$RET" ]; then + DEFAULTLOCALE="$RET" +else + # Just in case + DEFAULTLOCALE="C" +fi +# If present, keep track of charset or modifier we got from languagechooser +# This charset or modifier is in the fallback locale +EXTRA_LANGUAGECHOOSER=`echo $FALLBACKLOCALE | sed -e 's/[EMAIL PROTECTED]//'` + +FIRST_LANG=$(echo $LANGUAGELIST | sed -e 's/:.*$//') + +if grep -q "^:$FIRST_LANG\$" $SHORTLISTS; then + use_lang=$FIRST_LANG +elif grep -q "^:$LANGUAGE\$" $SHORTLISTS; then + use_lang=$LANGUAGE +else + use_lang="" +fi + +# At this step we should have either xx, or xx_YY in LANGNAME +if [ "$LANGUAGE" != "C" ]; then + STATE=1 + LASTSTATE=3 + fullprio=critical + while [ "$STATE" != 0 -a "$STATE" -le "$LASTSTATE" ]; do + case "$STATE" in + 1) + # If the locale includes a country, then + # don't display the short list, and only show the + # full list at medium priority. + if (echo $DEFAULTLOCALE | grep "_" >/dev/null 2>&1) ; then + askedshort=0 + fullprio=medium + else + if [ "$use_lang" ]; then + # Build a short list of supported locales for + # the language. + OLD_IFS="$IFS" + IFS=' +' + COUNTRIES=$(cat_shortlist $use_lang | sed -e 's/^.* //'); + SHORTLIST="" + for name in $COUNTRIES; do + if [ ! -z "${SHORTLIST}" ]; then + SHORTLIST="${SHORTLIST}, " + fi + countryname=$(echo "${INDENT}${name}" | sed -e 's/,/\\,/') + SHORTLIST="${SHORTLIST}${countryname}" + done + IFS="$OLD_IFS" + db_subst $shortlist SHORTLIST "${SHORTLIST}" + db_subst $shortlist DEFAULTLOCALE "${DEFAULTLOCALE}" + db_input critical $shortlist || [ $? -eq 30 ] + askedshort=1 + else + askedshort=0 + fi + fi + ;; + 2) + db_get $shortlist + if [ "$askedshort" = 1 ] && [ "$RET" != "other" ]; then + COUNTRYCODE="$(loccountry2code "$RET" $use_lang )" || true + if [ -n "$COUNTRYCODE" ]; then + break + fi + fi + + db_subst $fulllist DEFAULTLOCALE "${DEFAULTLOCALE}" + db_input $fullprio $fulllist || [ $? -eq 30 ] + ;; + 3) + db_get $fulllist + COUNTRYCODE="$(country2code "$RET")" || true + if [ -n "$COUNTRYCODE" ]; then + break + else + # User probably selected a region. + STATE=2 + continue + fi + ;; + esac + + if db_go; then + STATE=$(($STATE + 1)) + else + STATE=$(($STATE - 1)) + fi + done + + if [ "$STATE" = 0 ]; then + exit 10 # back out to main menu + fi +fi + +db_set "$countrycode" "$COUNTRYCODE" +log "$countrycode = '$COUNTRYCODE'" + +# Search for a supported locale which most closely resembles. +LOCALE="" +log "LANGUAGE = '$LANGUAGE'" +log "LANGUAGECODE_LANGUAGECHOOSER = '$LANGUAGECODE_LANGUAGECHOOSER'" +log "COUNTRYCODE = '$COUNTRYCODE'" +log "COUNTRYCODE_LANGUAGECHOOSER = '$COUNTRYCODE_LANGUAGECHOOSER'" +log "LOCALE_LANGUAGECHOOSER = '$LOCALE_LANGUAGECHOOSER'" + +for entry in ${LANGUAGE}_${COUNTRYCODE}${EXTRA_LANGUAGECHOOSER} \ + ${LANGUAGE}_${COUNTRYCODE}; do + if grep -q "^${entry}$" $SUPPORTEDLOCALES; then + # Special handling of cases where the locale + # in languagechooser is NOT the combination of + # language_COUNTRY. Used for Norwegian Bokmal transition + # in order to keep no_NO as locale. May be used in the + # future for other special cases, so we'd better keep this + if \ + [ "${LANGUAGE}" = "${LANGUAGECODE_LANGUAGECHOOSER}" \ + -a \ + "${COUNTRYCODE}" = "${COUNTRYCODE_LANGUAGECHOOSER}" \ + -a \ + "${LANGUAGE}_${COUNTRYCODE}" != "${LOCALE_LANGUAGECHOOSER}" \ + ] ; then + # In details : we revert back to the locale + # defined in languagechooser if countrychooser + # did NOT induce change in language and country + # but the resulting locale is different from the + # one we had in languagechooser + LOCALE=${LOCALE_LANGUAGECHOOSER} + else + LOCALE="${entry}" + fi + break + fi +done + +# Fall back to a supported locale. +if [ -z "${LOCALE}" ]; then + LOCALE="${FALLBACKLOCALE}" + log "falling back to locale '${FALLBACKLOCALE}'" +fi + +# Set the locale. +db_set "$localecode" "${LOCALE}" +log "$localecode = '${LOCALE}'" + +# The code below tries to add lang_COUNTRY at the beginning of the language +# list we got from languagechooser +# Example: +# -user chooses "Arabic" at languagechooser-->she gets "ar_EG:ar:en_US:en" +# (see the languagelist file from languagechooser) +# -she chooses "Syria" as country-->then we end up with +# "ar_SY:ar_EG:ar:en_UC:en" +# We shouldn't just add this before the former list in case the country +# is changed several times. +if [ "$COUNTRYCODE" != "$COUNTRYCODE_LANGUAGECHOOSER" -a -n "$COUNTRYCODE" -a -n $LANGUAGE ]; then + LANGUAGELIST=${LANGUAGE}_${COUNTRYCODE}:${LANGUAGELIST} + # Languagelist setting + db_set "$languagecode" "$LANGUAGELIST" + log "$languagecode = '$LANGUAGELIST'" +fi + +exit 0 diff -ruN countrychooser.orig/debian/dirs countrychooser/debian/dirs --- countrychooser.orig/debian/dirs 1970-01-01 02:00:00.000000000 +0200 +++ countrychooser/debian/dirs 2004-09-01 14:14:29.000000000 +0300 @@ -0,0 +1 @@ +usr/bin diff -ruN countrychooser.orig/debian/postinst countrychooser/debian/postinst --- countrychooser.orig/debian/postinst 2004-08-17 23:49:49.000000000 +0300 +++ countrychooser/debian/postinst 2004-09-01 14:11:33.000000000 +0300 @@ -1,286 +1,5 @@ -#!/bin/sh -set -e +#!/bin/sh -e -. /usr/share/debconf/confmodule +PATH=$PATH:. -db_capb backup - -INDENT=" " - -localecode="debian-installer/locale" -fallbacklocalecode="debian-installer/fallbacklocale" -languagechooserlocalecode="languagechooser/locale" -languagecode="debian-installer/language" -countrycode="debian-installer/country" -languagechooserlanguage="languagechooser/language-name" -shortlist="countrychooser/country-name-shortlist" -fulllist="countrychooser/country-name" - -# This is the iso_3166.tab file location -ISO3166TAB=/usr/share/iso-codes/iso_3166.tab -SUPPORTEDLOCALES=/etc/SUPPORTED-short -SHORTLISTS=/etc/shortlists - -for list in $ISO3166TAB ; do - if [ -f "$list" ]; then - countries="$list" - fi -done - -error() { - logger -t countrychooser "error: $@" - exit 1 -} - -log() { - logger -t countrychooser "info: $@" -} - -code2country() { - COUNTRYCODE="$1" - line=`grep "$COUNTRYCODE" $countries` - - if [ -n "$line" ]; then - # Remember that country names may have spaces so the code - # is different than in country2code. - printf "$INDENT" - echo $line | cut -b 4- - else - error "Unable to locate info on country '$COUNTRYCODE'" - fi -} - -country2code() { - COUNTRYNAME=$(echo "$1" | sed "s/^$INDENT//" | sed 's/\\,/,/g') - line=`grep "$COUNTRYNAME$" $countries` - - if [ -n "$line" ]; then - set $line - if [ -n "$1" ]; then - echo "$1" - fi - fi -} - -cat_shortlist() { - (out="" - IFS=' -' - while read line; do - if $(echo "$line" | grep -q "^:$1\$"); then - out=1 - elif $(echo "$line" | grep -q "^:"); then - out="" - elif [ "$out" ]; then - echo "$line" - fi - done - ) < $SHORTLISTS -} - -loccountry2code() { - COUNTRYNAME=$(echo "$1" | sed "s/^$INDENT//" | sed 's/\\,/,/g') - line=`cat_shortlist $2| grep "$COUNTRYNAME\$"` - if [ -n "$line" ]; then - set $line - if [ -n "$1" ]; then - echo "$1" - fi - fi -} - -# First grab back the country we got from languagechooser -# (or from elsewhere) and populate the debconf database with -# it so that it becomes the default choice -db_get "$countrycode" -if [ -n "$RET" ]; then - # Remember which code was first used - # This is needed at the end of the script - COUNTRYCODE_LANGUAGECHOOSER="$RET" - COUNTRY_LANGUAGECHOOSER="$(code2country "$RET")" - db_set "$fulllist" "${COUNTRY_LANGUAGECHOOSER}" - db_set "$shortlist" "${COUNTRY_LANGUAGECHOOSER}" -fi - - -# Then grab back the language we got from languagechooser -db_get "$languagechooserlanguage" -if [ -n "$RET" ]; then - LANGNAME="$RET" - # languagemap is a script from languagechooser which - # returns the language list in LANGUAGELIST and the - # language alone in LANGUAGE - if ! . languagemap ; then - LANGUAGE=C - else - # We need to remember these for further use - LOCALE_LANGUAGECHOOSER=$LOCALE - LANGUAGECODE_LANGUAGECHOOSER=$LANGUAGE - fi -fi - -# Then grab back the locale we got from languagechooser -db_get "$localecode" -if [ -n "$RET" ]; then - DEFAULTLOCALE="$RET" -else - # Just in case - DEFAULTLOCALE="C" -fi -# If present, keep track of charset or modifier we got from languagechooser -# This charset or modifier is in the fallback locale -EXTRA_LANGUAGECHOOSER=`echo $FALLBACKLOCALE | sed -e 's/[EMAIL PROTECTED]//'` - -FIRST_LANG=$(echo $LANGUAGELIST | sed -e 's/:.*$//') - -if grep -q "^:$FIRST_LANG\$" $SHORTLISTS; then - use_lang=$FIRST_LANG -elif grep -q "^:$LANGUAGE\$" $SHORTLISTS; then - use_lang=$LANGUAGE -else - use_lang="" -fi - -# At this step we should have either xx, or xx_YY in LANGNAME -if [ "$LANGUAGE" != "C" ]; then - STATE=1 - LASTSTATE=3 - fullprio=critical - while [ "$STATE" != 0 -a "$STATE" -le "$LASTSTATE" ]; do - case "$STATE" in - 1) - # If the locale includes a country, then - # don't display the short list, and only show the - # full list at medium priority. - if (echo $DEFAULTLOCALE | grep "_" >/dev/null 2>&1) ; then - askedshort=0 - fullprio=medium - else - if [ "$use_lang" ]; then - # Build a short list of supported locales for - # the language. - OLD_IFS="$IFS" - IFS=' -' - COUNTRIES=$(cat_shortlist $use_lang | sed -e 's/^.* //'); - SHORTLIST="" - for name in $COUNTRIES; do - if [ ! -z "${SHORTLIST}" ]; then - SHORTLIST="${SHORTLIST}, " - fi - countryname=$(echo "${INDENT}${name}" | sed -e 's/,/\\,/') - SHORTLIST="${SHORTLIST}${countryname}" - done - IFS="$OLD_IFS" - db_subst $shortlist SHORTLIST "${SHORTLIST}" - db_subst $shortlist DEFAULTLOCALE "${DEFAULTLOCALE}" - db_input critical $shortlist || [ $? -eq 30 ] - askedshort=1 - else - askedshort=0 - fi - fi - ;; - 2) - db_get $shortlist - if [ "$askedshort" = 1 ] && [ "$RET" != "other" ]; then - COUNTRYCODE="$(loccountry2code "$RET" $use_lang )" || true - if [ -n "$COUNTRYCODE" ]; then - break - fi - fi - - db_subst $fulllist DEFAULTLOCALE "${DEFAULTLOCALE}" - db_input $fullprio $fulllist || [ $? -eq 30 ] - ;; - 3) - db_get $fulllist - COUNTRYCODE="$(country2code "$RET")" || true - if [ -n "$COUNTRYCODE" ]; then - break - else - # User probably selected a region. - STATE=2 - continue - fi - ;; - esac - - if db_go; then - STATE=$(($STATE + 1)) - else - STATE=$(($STATE - 1)) - fi - done - - if [ "$STATE" = 0 ]; then - exit 10 # back out to main menu - fi -fi - -db_set "$countrycode" "$COUNTRYCODE" -log "$countrycode = '$COUNTRYCODE'" - -# Search for a supported locale which most closely resembles. -LOCALE="" -log "LANGUAGE = '$LANGUAGE'" -log "LANGUAGECODE_LANGUAGECHOOSER = '$LANGUAGECODE_LANGUAGECHOOSER'" -log "COUNTRYCODE = '$COUNTRYCODE'" -log "COUNTRYCODE_LANGUAGECHOOSER = '$COUNTRYCODE_LANGUAGECHOOSER'" -log "LOCALE_LANGUAGECHOOSER = '$LOCALE_LANGUAGECHOOSER'" - -for entry in ${LANGUAGE}_${COUNTRYCODE}${EXTRA_LANGUAGECHOOSER} \ - ${LANGUAGE}_${COUNTRYCODE}; do - if grep -q "^${entry}$" $SUPPORTEDLOCALES; then - # Special handling of cases where the locale - # in languagechooser is NOT the combination of - # language_COUNTRY. Used for Norwegian Bokmal transition - # in order to keep no_NO as locale. May be used in the - # future for other special cases, so we'd better keep this - if \ - [ "${LANGUAGE}" = "${LANGUAGECODE_LANGUAGECHOOSER}" \ - -a \ - "${COUNTRYCODE}" = "${COUNTRYCODE_LANGUAGECHOOSER}" \ - -a \ - "${LANGUAGE}_${COUNTRYCODE}" != "${LOCALE_LANGUAGECHOOSER}" \ - ] ; then - # In details : we revert back to the locale - # defined in languagechooser if countrychooser - # did NOT induce change in language and country - # but the resulting locale is different from the - # one we had in languagechooser - LOCALE=${LOCALE_LANGUAGECHOOSER} - else - LOCALE="${entry}" - fi - break - fi -done - -# Fall back to a supported locale. -if [ -z "${LOCALE}" ]; then - LOCALE="${FALLBACKLOCALE}" - log "falling back to locale '${FALLBACKLOCALE}'" -fi - -# Set the locale. -db_set "$localecode" "${LOCALE}" -log "$localecode = '${LOCALE}'" - -# The code below tries to add lang_COUNTRY at the beginning of the language -# list we got from languagechooser -# Example: -# -user chooses "Arabic" at languagechooser-->she gets "ar_EG:ar:en_US:en" -# (see the languagelist file from languagechooser) -# -she chooses "Syria" as country-->then we end up with -# "ar_SY:ar_EG:ar:en_UC:en" -# We shouldn't just add this before the former list in case the country -# is changed several times. -if [ "$COUNTRYCODE" != "$COUNTRYCODE_LANGUAGECHOOSER" -a -n "$COUNTRYCODE" -a -n $LANGUAGE ]; then - LANGUAGELIST=${LANGUAGE}_${COUNTRYCODE}:${LANGUAGELIST} - # Languagelist setting - db_set "$languagecode" "$LANGUAGELIST" - log "$languagecode = '$LANGUAGELIST'" -fi - -exit 0 +countrychooser diff -ruN countrychooser.orig/debian/rules countrychooser/debian/rules --- countrychooser.orig/debian/rules 2004-05-08 02:58:31.000000000 +0300 +++ countrychooser/debian/rules 2004-09-01 14:10:08.000000000 +0300 @@ -34,6 +34,7 @@ dh_testroot dh_clean -k dh_installdirs etc + dh_install countrychooser usr/bin # The following while we have no other way to get SUPPORTED # Should become useless when we will have it install -m644 debian/SUPPORTED-short debian/$(PACKAGE)/etc/SUPPORTED-short
diff -ruN languagechooser.orig/languagechooser languagechooser/languagechooser --- languagechooser.orig/languagechooser 2004-07-25 00:47:11.000000000 +0300 +++ languagechooser/languagechooser 2004-09-01 16:59:07.000000000 +0300 @@ -15,6 +15,12 @@ logger -t languagechooser "info: $@" } +# Any other sane way to detect if this is the first run? +db_get "$languagechooserlocalecode" +if [ -z "$RET" ]; then + is_firsttime="yes" +fi + # debconf/language is an alias for debian-installer/language db_register "$languagecode" "debconf/language" @@ -94,6 +100,22 @@ ;; esac +# FIXME: If the user changes his/her mind for the language later, we +# should call countrychooser to resolve the languagecode, so that the +# selected language can be used in the second stage installation. +# This is just a workaround until we find a better solution. +if [ ! "$is_firsttime" ]; then + ( + db_get debconf/priority + save_priority="$RET" + + db_set debconf/priority critical + countrychooser + + db_set debconf/priority $save_priority + ) || true +fi + log "$localecode = '$LOCALE'" log "$fallbacklocalecode = '$FALLBACKLOCALE'" log "$languagechooserlocalecode = '$LOCALE'"
signature.asc
Description: Digital signature