File indexing completed on 2024-04-14 04:47:55

0001 #!/bin/bash
0002 # You usually should not call this script, it documents the process.
0003 # Use download-pos.sh instead, it will fetch the translations
0004 # and the docbooks which are considered to be ready from l10n.kde.org.
0005 # To extract only a subset of the docbooks, pass their paths as parameters,
0006 # e.g. ./extract-merge.sh po/pt/kid3.po.
0007 
0008 set -e
0009 _project="kid3"
0010 
0011 if test -n "$1"; then
0012   _catalogs=$*
0013 else
0014   _catalogs=`find po -name '*.po'`
0015 fi
0016 
0017 if ! test -f po/$_project.pot; then
0018   echo "Extracting messages"
0019   mkdir -p po
0020   xml2pot en/index.docbook >po/$_project.pot
0021 else
0022   echo "NOTE: Keeping po/$_project.pot, delete it to extract messages"
0023 fi
0024 
0025 echo "Merging translations"
0026 for _cat in $_catalogs; do
0027   echo $_cat
0028   msgmerge --quiet --update --backup=none $_cat po/${_project}.pot
0029 done
0030 
0031 echo "Generating docbooks"
0032 for _cat in $_catalogs; do
0033   _lc=${_cat#po/}
0034   _lc=${_lc%/*}
0035   echo docs/$_lc/index.docbook
0036   mkdir -p docs/$_lc
0037   po2xml en/index.docbook $_cat >docs/$_lc/index.docbook
0038   _lang=$(sed -nE 's/"Language-Team:\s*(\S+)\s.*/\1/p' $_cat)
0039   test -n "$_lang" && sed -i "s/ENTITY % English/ENTITY % $_lang/" docs/$_lc/index.docbook
0040 done
0041 
0042 echo "Done"