[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#242006: patch: localize short list of countries



On Fri, Apr 16, 2004 at 08:12:39AM +0200, Christian Perrier wrote:
> Quoting Eugeniy Meshcheryakov (eugen@univ.kiev.ua):
> > Package: countrychooser
> > Version: SVN
> > Severity: normal
> > Followup-For: Bug #242006
> > 
> >    Attached patch adds localized short list support to countrychooser.
> > Short lists are generated during package build and stored in
> > /usr/share/shortnames/.
> 
> This patch did not trigger a lot of reactions.....except immediately
> after its publication. We had a few exchanges on IRC.
> 
> Joey was concerned about the increased size of countrychooser. Below
> are the facts:
> 
> Without the patch:
>  new debian package, version 2.0.
>  size 44080 bytes: control archive= 43192 bytes.
>      349 bytes,    11 lines      control
>     5248 bytes,   203 lines   *  postinst             #!/bin/sh
>   172132 bytes,   294 lines      templates
>  Installed-Size: 200
> 
> 
> With the patch:
> 
>  new debian package, version 2.0.
>  size 44998 bytes: control archive= 43261 bytes.
>      349 bytes,    11 lines      control
>     5642 bytes,   223 lines   *  postinst             #!/bin/sh
>   172132 bytes,   294 lines      templates
>  Installed-Size: 260
> 
> I think you get the point-->Installed-Size grows up by 60kb which
> could make the root floppy too big.
> 
> This is why I suggest delaying this change for post beta4.

I've attached a patch that generates the short translated lists at
runtime.  It requires that paste be added to busybox and probably
mishandles names that include commas, but it should still be
smaller than pregenerating the lists.

-- 
Matt Kraai            kraai@ftbfs.org            http://ftbfs.org/
Index: debian/postinst
===================================================================
--- debian/postinst	(revision 13672)
+++ debian/postinst	(working copy)
@@ -115,6 +115,9 @@
 				# Build a short list of supported locales fo
 				# the language.
 				SHORTLIST=''
+				sed -n '/^Name: countrychooser\/country-name$/,/^$/s/^Choices: //p' /var/cache/lib/templates.dat | sed 's/,/\n/g' > /tmp/countrychooser.english
+				sed -n '/^Name: countrychooser\/country-name$/,/^$/s/^Choices-'$LANGUAGE'\.UTF-8: //p' /var/cache/lib/templates.dat | sed -e 's/,/\n/g' > /tmp/countrychooser.$LANGUAGE
+				paste /tmp/countrychooser.english /tmp/countrychooser.$LANGUAGE | sed 's/\(.*\)\t\(.*\)/s\/\1\/\2\//' > /tmp/countrychooser.translate
 				for code in $(grep -e "^$LANGUAGE" $SUPPORTEDLOCALES | cut -b 4-5 | sort | uniq); do
 					line=`grep -e "^$code" $ISO3166TAB`
 					if [ "$line" ] ; then
@@ -123,7 +126,7 @@
 						set $line
 						IFS="$OLD_IFS"
 						if [ "$2" ]; then
-							countryname=$(echo "${INDENT}$2" | sed 's/,/\\,/g');
+							countryname=$(echo "${INDENT}$2" | sed -f /tmp/countrychooser.translate -e 's/,/\\,/g')
 						fi
 						if [ ! -z "${SHORTLIST}" ]; then
 							SHORTLIST="${SHORTLIST}, "
@@ -131,6 +134,7 @@
 						SHORTLIST="${SHORTLIST}${countryname}"
 					fi
 				done
+				rm /tmp/countrychooser.english /tmp/countrychooser.$LANGUAGE /tmp/countrychooser.script
 				db_subst $shortlist SHORTLIST "${SHORTLIST}"
 				db_subst $shortlist DEFAULTLOCALE "${DEFAULTLOCALE}"
 				db_input critical $shortlist || [ $? -eq 30 ]

Reply to: