You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

96 lines
3.5 KiB

  1. #!/bin/sh
  2. set -e
  3. # Script for generating a debconf templates file from both files
  4. # in debian/po/*.po and country names translations from the
  5. # iso-codes package
  6. #
  7. # Some variables
  8. ISO3166TAB=/usr/share/iso-codes/iso_3166.tab
  9. export ISO3166TAB
  10. # Translations location (relative to the build root directory)
  11. ISO3166TRANSLATIONS=debian/iso-codes
  12. # Get the ordered list of countries from the iso_3166.tab, sorted
  13. # according to the regionmap.
  14. #
  15. # We need to escape commas by preceding them with a backslash.
  16. HTTPCODECHOICES=`cat debian/httplist-countries`
  17. FTPCODECHOICES=`cat debian/ftplist-countries`
  18. printf "Creating the list of countries for HTTP mirrors..."
  19. # We need building the choices list with English names rather than codes
  20. HTTPCHOICES=$(cat debian/httplist-countries | \
  21. (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))
  22. printf " Done.\n"
  23. printf "Creating the list of countries for FTP mirrors..."
  24. FTPCHOICES=$(cat debian/ftplist-countries | \
  25. (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))
  26. printf " Done.\n"
  27. printf "Insert the lists of choices into the templates file..."
  28. # Now put this list as the choices in the templates
  29. # and defined this field as translatable (__Choices hack)
  30. cat debian/templates-in | \
  31. perl -pe 's/\@httpcountrylist\@/'"$HTTPCHOICES"'/g' | \
  32. perl -pe 's/\@ftpcountrylist\@/'"$FTPCHOICES"'/g' | \
  33. sed "/^_Choices: enter/s/_Choices:/__Choices:/g" \
  34. >debian/templates.tmp
  35. printf " Done.\n"
  36. # Create a temporary "pobuild" directory
  37. rm -rf debian/pobuild >/dev/null 2>&1
  38. mkdir debian/pobuild
  39. # Create the appropriate POTFILES.in file there
  40. cat >debian/pobuild/POTFILES.in <<EOF
  41. [type: gettext/rfc822deb] templates.tmp
  42. EOF
  43. # Create the appropriate output file also
  44. cat >debian/pobuild/output <<EOF
  45. 2 utf8
  46. EOF
  47. # Run debconf-updatepo on this directory
  48. # -->this will create pobuild/templates.pot
  49. debconf-updatepo --podir debian/pobuild
  50. printf "Include country names translations into the templates file:\n"
  51. # The following takes place for each language
  52. # (each existing file in debian/po)
  53. for pofile in debian/po/*.po ; do
  54. pofilename=`basename $pofile`
  55. langname=`basename $pofilename .po`
  56. printf " $langname..."
  57. # If the country names are translated, we need to merge
  58. # the translation with the templates translations
  59. if [ -f $ISO3166TRANSLATIONS/$pofilename ]
  60. then
  61. # Output is verbose, don't worry
  62. # Copy other templates translations
  63. cp debian/po/$pofilename debian/pobuild/$pofilename.copied
  64. # Update it with templates.pot
  65. msgmerge -U debian/pobuild/$pofilename.copied \
  66. debian/pobuild/templates.pot 2>/dev/null
  67. # merge with iso-codes translations
  68. # if charsets differ, this may output some "error" messages we ignore
  69. msgmerge debian/iso-codes/$pofilename \
  70. debian/pobuild/$pofilename.copied \
  71. > debian/pobuild/$pofilename 2>/dev/null
  72. # clean out the generated file
  73. msgmerge -U debian/pobuild/$pofilename \
  74. debian/pobuild/templates.pot 2>/dev/null
  75. # Else we just use what's translated
  76. else
  77. cp $pofile debian/pobuild/$pofilename && true
  78. fi
  79. printf "Done.\n"
  80. done
  81. # and now we generate the templates file from all this
  82. PODEBCONF_LIB=. po2debconf --podir debian/pobuild debian/templates.tmp >debian/choose-mirror.templates