#!/bin/sh LANG=C ROOT=$(cd .. && pwd) PRGNAM=installer-translations VERSION=14.2.1.5 BUILD=$(date -u +%Y%m%d) ARCH=noarch TAG=${TAG:-slint} CWD=$(pwd) TMP=$CWD PKG=$TMP/package-$PRGNAM OUTPUT=$CWD rm -rf $PKG mkdir -p $PKG/wip # Build the PO files # We first need to format the PO files in such a way that msggrep will # work. msggrep ignores references like: # File: , line: # But expects instead: #: : # . ./SeTlocales for i in $(ls $ROOT/Crowdin/latest_translations/auto|grep -v pot|grep -v prev); do sed "/^#/{s/# File: /#: /;s/, line:[ ]*/:/}" $ROOT/Crowdin/latest_translations/auto/$i > $PKG/wip/$i msggrep -o $PKG/${i%%.*}.${DOMAINNAME}.po -N *auto $PKG/wip/$i done for i in $(ls $ROOT/Crowdin/latest_translations/setup|grep -v pot|grep -v prev); do sed "/^#/{s/# File: /#: /;s/, line:[ ]*/:/}" $ROOT/Crowdin/latest_translations/setup/$i > $PKG/wip/$i msggrep -o $PKG/${i%%.*}.${DOMAINNAME}.po -N setup $PKG/wip/$i done for i in $(ls $ROOT/Crowdin/latest_translations/rc.S|grep -v pot|grep -v prev); do sed "/^#/{s/# File: /#: /;s/, line:[ ]*/:/}" $ROOT/Crowdin/latest_translations/rc.S/$i > $PKG/wip/$i msggrep -o $PKG/${i%%.*}.${DOMAINNAME}.po -N rc.S $PKG/wip/$i done for i in $(ls $ROOT/Crowdin/latest_translations/manual_installer|grep -v pot|grep -v prev); do sed "/^#/{s/# File: /#: /;s/, line:[ ]*/:/}" $ROOT/Crowdin/latest_translations/manual_installer/$i > $PKG/wip/$i msggrep -o $PKG/${i%%.*}.${DOMAINNAME}.po \ $(while read j; do printf " -N *$j";done < $ROOT/Crowdin/latest_sources/scripts_in_manual_installer.txt) $PKG/wip/$i done # Compile the message catalogs cd $PKG/wip for k in auto setup rc.S manual_installer; do DOMAINNAME=$k for j in $(ls *$k.po); do ll_TT=${j%%.*} SeTLocaleDir if [ "$LocaleDir" = "missing" ]; then printf %b "I don't know where to install the message catalog for ${ll_TT}.\n" printf %b "Please request that the file $ROOT/scripts/SeTlocales be completed\n" exit fi MO_DIR=$PKG/usr/share/locale/$LocaleDir/LC_MESSAGES mkdir -p $MO_DIR msgfmt --strict -c -v --statistics -o $MO_DIR/${DOMAINNAME}.mo $j 2> error # /storage/Traduction/build/package-installer-translations/wip/ru_RU.setup.po : 41 messages traduits, 2 messages non traduits. if ! grep -q " translated messages" error; then translated=0 else grep "^.*$j: " error > stat translated=$(sed "s@.*: @@;s@ .*@@" stat) fi if ! grep -q "untranslated" stat; then untranslated=0 else untranslated=$(sed "s@.* translated message[s]\{0,1\}, @@;s@ .*@@" stat) total=$((translated+untranslated)) percentage=$((translated*100/total)) if [ $percentage -lt 85 ]; then rm $MO_DIR/${DOMAINNAME}.mo echo "$j rejected, only ${percentage}% translated." else chown root:root $MO_DIR/${DOMAINNAME}.mo chmod 644 $MO_DIR/${DOMAINNAME}.mo fi fi done done mkdir -p $PKG/usr/bin cp $CWD/doc $PKG/usr/bin chmod 755 $PKG/usr/bin/doc mkdir -p $PKG/doc asciidoctor -D $PKG/doc $ROOT/Crowdin/latest_sources/HandBook.adoc # list of translations in translated_HandBooks asciidoctor -D $PKG/doc $ROOT/Crowdin/latest_translations/HandBook/fr_FR.HandBook.adoc asciidoctor -D $PKG/doc $ROOT/Crowdin/latest_translations/HandBook/nl_NL.HandBook.adoc asciidoctor -D $PKG/doc $ROOT/Crowdin/latest_translations/HandBook/pt_PT.HandBook.adoc (cd $PKG/usr/doc ln -s fr_FR.HandBook.html fr.HandBook.html ln -s nl_NL.HandBook.html nl.HandBook.html ln -s pt_PT.HandBook.html pt.HandBook.html ) cd - rm -rf $PKG/wip rm -f $PKG/*po mkdir -p $PKG/install cat << EOF > $PKG/install/slack-desc |-----handy-ruler------------------------------------------------------| installer-translations: installer-translations (translations of messages in Slint installer) installer-translations: installer-translations: This package contains translations of messages displayed by installer-translations: configurations scripts included in the Slint installer, thanks to the installer-translations: translators of the Slint project. Visit our website: http://slint.fr installer-translations: installer-translations: The Slint HandBook is also included, in English and in languages in installer-translations: which its translation has been completed. installer-translations: installer-translations: installer-translations: EOF ( cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz} )