Browse Source

List country codes as C choices for mirror/*/countries, and add a

Choices-en.UTF-8 with the English country names (closes: #311021).

r28101
tags/1.11
Colin Watson 16 years ago
parent
commit
084c92013d
4 changed files with 61 additions and 6 deletions
  1. +2
    -0
      debian/changelog
  2. +15
    -0
      get-iso-codes
  3. +31
    -0
      map-cc
  4. +13
    -6
      mktemplates

+ 2
- 0
debian/changelog View File

@@ -5,6 +5,8 @@ choose-mirror (1.11) UNRELEASED; urgency=low
space-separated, e.g. "i386 amd64"; lines of the form "!hurd-i386
!netbsd-i386" are supported to say that the archive has all but the
listed architectures, although that should be used with caution.
- List country codes as C choices for mirror/*/countries, and add a
Choices-en.UTF-8 with the English country names (closes: #311021).

-- Colin Watson <cjwatson@debian.org> Wed, 18 May 2005 18:13:05 +0100



+ 15
- 0
get-iso-codes View File

@@ -14,3 +14,18 @@ for i in `find /usr/share/locale/ -name iso_3166.mo` ; do
msgunfmt $i >debian/iso-codes/${language}.po 2>/dev/null
done

DATE="$(date +'%Y-%m-%d %H:%M%z')"
cat <<EOF >debian/iso-codes/en.po
msgid ""
msgstr ""
"Project-Id-Version: iso_3166 CVS\\n"
"Report-Msgid-Bugs-To: Alastair McKinstry <mckinstry@debian.org>\\n"
"POT-Creation-Date: $DATE\\n"
"PO-Revision-Date: $DATE\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=UTF-8\\n"
"Content-Transfer-Encoding: 8bit\\n"

EOF
perl -pe 's/.*?\t(.*)/msgid "$1"\nmsgstr "$1"\n/' \
</usr/share/iso-codes/iso_3166.tab >>debian/iso-codes/en.po

+ 31
- 0
map-cc View File

@@ -0,0 +1,31 @@
#! /usr/bin/perl -w
use strict;

my $iso3166tab = shift;

# Get mapping of country names to country codes (i.e. reverse of
# iso_3166.tab).
my %iso3166rev;
open ISO3166TAB, '<:utf8', "$iso3166tab" or die "open $iso3166tab: $!";
while (<ISO3166TAB>) {
/^([A-Z]+)\t(.*)$/ or next;
$iso3166rev{$2} = $1;
}
close ISO3166TAB;

# Stringtable output is easier to handle.
open SOURCESTRINGS, '-|:utf8', 'msgcat', '--stringtable-output', '-'
or die "open msgcat for source: $!";
open TARGETSTRINGS, '|-:utf8', 'msgcat', '--stringtable-input', '-s', '-'
or die "open msgcat for target: $!";
while (<SOURCESTRINGS>) {
if (/^"(.+?)" = "(.*?)";$/) {
if (exists $iso3166rev{$1}) {
print TARGETSTRINGS qq{"$iso3166rev{$1}" = "$2";\n};
}
} else {
print TARGETSTRINGS;
}
}
close SOURCESTRINGS;
close TARGETSTRINGS or die "close msgcat for target: $!";

+ 13
- 6
mktemplates View File

@@ -21,13 +21,11 @@ FTPCODECHOICES=`cat debian/ftplist-countries`

printf "Creating the list of countries for HTTP mirrors..."
# We need building the choices list with English names rather than codes
HTTPCHOICES=$(cat debian/httplist-countries | \
(read a; echo -n `grep -i "^$a" $ISO3166TAB | cut -b 4-` ; while read b; do echo -n ", "`grep -i "^$b" $ISO3166TAB | cut -b 4- | sed 's/,/\\\\\\\\,/g'`; done; echo))
HTTPCHOICES="$(xargs < debian/httplist-countries | sed 's/ /, /g')"
printf " Done.\n"

printf "Creating the list of countries for FTP mirrors..."
FTPCHOICES=$(cat debian/ftplist-countries | \
(read a; echo -n `grep -i "^$a" $ISO3166TAB | cut -b 4-` ; while read b; do echo -n ", "`grep -i "^$b" $ISO3166TAB | cut -b 4- | sed 's/,/\\\\\\\\,/g'`; done; echo))
FTPCHOICES="$(xargs < debian/ftplist-countries | sed 's/ /, /g')"
printf " Done.\n"

printf "Insert the lists of choices into the templates file..."
@@ -70,10 +68,12 @@ for pofile in debian/po/*.po ; do
if [ -f $ISO3166TRANSLATIONS/$pofilename ]
then
# Output is verbose, don't worry
# Convert translations to UTF-8
# Convert translations to UTF-8, and map country names to country
# codes in iso-codes translations
msgconv -t UTF-8 debian/po/$pofilename \
> debian/pobuild/$pofilename.other
msgconv -t UTF-8 debian/iso-codes/$pofilename \
msgconv -t UTF-8 "$ISO3166TRANSLATIONS/$pofilename" \
| ./map-cc "$ISO3166TAB" \
> debian/pobuild/$pofilename.iso-codes
# Update other template translations with templates.pot
msgmerge -U debian/pobuild/$pofilename.other \
@@ -92,6 +92,13 @@ for pofile in debian/po/*.po ; do
printf "Done.\n"
done

if [ ! -f debian/po/en.po ]; then
printf " en..."
./map-cc "$ISO3166TAB" < "$ISO3166TRANSLATIONS/en.po" > debian/pobuild/en.po
msgmerge -U debian/pobuild/en.po debian/pobuild/templates.pot 2>/dev/null
printf "Done.\n"
fi

# and now we generate the templates file from all this
PODEBCONF_LIB=. po2debconf --podir debian/pobuild debian/templates.tmp >debian/choose-mirror.templates



Loading…
Cancel
Save