Bug#275904: Patch for localechooser to set the default country at build time and not run time
tags 275904 patch
thanks
The attached patch switches localechooser to use a default country for
BOTH the short and long list, which can be set at build time.
It adds a "translatable" Default field to the templates, where the
translators should put the ISO code of the country they want to be
default in the country choosing screens.
I have tested it on local builds and will continue testing it, but I
think it deserves some peer review.
--
diff -Nru localechooser.ori/debian/localechooser.templates-in localechooser/debian/localechooser.templates-in
--- localechooser.ori/debian/localechooser.templates-in 2005-06-22 21:58:45.000000000 +0200
+++ localechooser/debian/localechooser.templates-in 2005-06-23 08:49:46.000000000 +0200
@@ -51,6 +51,7 @@
Template: countrychooser/country-name
Type: select
Choices: @countrylist@
+_Default: US [ Translators: put here the ISO-3166 CODE of the country which should be selected as default for your language ]
# Notes to translators
# The country names are not part of this package
#
@@ -71,6 +72,7 @@
Type: select
__Choices: ${SHORTLIST}, other
_Description: Choose a country, territory or area:
+_Default: US [ Translators: put here the ISO-3166 CODE of the country which should be selected as default for your language ]
Based on your language, you are probably located in one of these countries
or regions.
diff -Nru localechooser.ori/localechooser localechooser/localechooser
--- localechooser.ori/localechooser 2005-06-22 21:58:45.000000000 +0200
+++ localechooser/localechooser 2005-06-22 22:03:36.000000000 +0200
@@ -323,10 +323,10 @@
shortlist_template="$shortlist-$use_lang"
db_register $shortlist_template $shortlist
# Set the default
- db_fget $shortlist seen
- if [ "$RET" = false ]; then
- db_set $shortlist $COUNTRYCODE_LANGUAGECHOOSER
- fi
+ #db_fget $shortlist seen
+ #if [ "$RET" = false ]; then
+ # db_set $shortlist $COUNTRYCODE_LANGUAGECHOOSER
+ #fi
db_input $shortprio $shortlist || [ $? -eq 30 ]
askedshort=1
fi
diff -Nru localechooser.ori/mk_shortlist_templates localechooser/mk_shortlist_templates
--- localechooser.ori/mk_shortlist_templates 2005-06-22 21:58:45.000000000 +0200
+++ localechooser/mk_shortlist_templates 2005-06-23 19:35:24.000000000 +0200
@@ -37,14 +37,23 @@
EN_DESCR=$(awk -v ITEM="Description:" -f template_get_item.awk \
$TEMPLATE_TMP)
-
# Add new templates for each language that needs a shortlist
for LANG in $SHORTLIST_LANGS; do
+
+ # Get the default value
+ LANG_DEFAULT_COUNTRY=$(awk -v ITEM="Default-$LANG.UTF-8:" -f template_get_item.awk \
+ $TEMPLATE_TMP | head -1)
+
echo "Language: $LANG"
-
+if [ -n "$LANG_DEFAULT_COUNTRY" ] ; then
+echo "Default: $LANG_DEFAULT_COUNTRY"
+fi
# Write the 'template header' to the file
echo "Template: $TEMPLATE_NAME-$LANG" >>$TEMPLATE_NEW
echo "Type: select" >>$TEMPLATE_NEW
+ if [ -n "$LANG_DEFAULT_COUNTRY" ] ; then
+ echo "$LANG_DEFAULT_COUNTRY" >>$TEMPLATE_NEW
+ fi
# Next we put the countrycodes in the untranslated shortlist
SHORTLIST=
Reply to: