diff --git a/ci/txcheck.sh b/ci/txcheck.sh index a28caaee9..6c5d86c77 100644 --- a/ci/txcheck.sh +++ b/ci/txcheck.sh @@ -8,6 +8,13 @@ # # Use --cleanup as an argument to clean things up. +# The files that are translated; should match the contents of .tx/config +TX_FILE_LIST="lang/calamares_en.ts lang/python.pot src/modules/dummypythonqt/lang/dummypythonqt.pot calamares.desktop" + +### COMMAND ARGUMENTS +# +# We need to define tx_cleanup for the --cleanup argument, although it's +# normally used much later in the script. tx_cleanup() { # Cleanup artifacs of checking @@ -22,6 +29,21 @@ if test "x$1" = "x--cleanup" ; then fi test -z "$1" || { echo "! Usage: txcheck.sh [--cleanup]" ; exit 1 ; } + +### FIND EXECUTABLES +# +# +XMLLINT="" +for _xmllint in xmllint +do + $_xmllint --version > /dev/null 2>&1 && XMLLINT=$_xmllint + test -n "$XMLLINT" && break +done + + +### CHECK WORKING DIRECTORY +# +# if git describe translation > /dev/null 2>&1 ; then : else @@ -42,8 +64,6 @@ test "$DATE_PREV" -le "$DATE_HEAD" || { echo "! Translation tag has not aged eno # Tag is good, do real work of checking strings: collect names of relevant files test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; } -# Print part after = for each source_file line and delete all the rest -TX_FILE_LIST=$( sed -e '/^source_file/s+.*=++p' -e d .tx/config ) for f in $TX_FILE_LIST ; do test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; } done @@ -56,14 +76,24 @@ tx_sum() git worktree add $WORKTREE_NAME $WORKTREE_TAG > /dev/null 2>&1 || { echo "! Could not create worktree." ; exit 1 ; } ( cd $WORKTREE_NAME && sh ci/txpush.sh --no-tx ) > /dev/null 2>&1 || { echo "! Could not re-create translations." ; exit 1 ; } - ( cd $WORKTREE_NAME && sed -i'' -e '/ /dev/null 2>&1 && LUPDATE=$_lupdate test -n "$LUPDATE" && break done - test -n "$LUPDATE" || { echo "! No working lupdate" ; lupdate -version ; exit 1 ; } +XMLLINT="" +for _xmllint in xmllint +do + $_xmllint --version > /dev/null 2>&1 && XMLLINT=$_xmllint + test -n "$XMLLINT" && break +done +# XMLLINT is optional + + +### CREATE TRANSLATIONS +# +# Use local tools (depending on type of source) to create translation +# sources, then push to Transifex + # Don't pull branding translations in, # those are done separately. _srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml" $LUPDATE -no-obsolete $_srcdirs -ts lang/calamares_en.ts -$LUPDATE -no-obsolete -extensions cxxtr src/libcalamares/locale -ts lang/tz_en.ts +# Updating the TZ only needs to happen when the TZ themselves are updated, +# very-very-rarely. +# $LUPDATE -no-obsolete -extensions cxxtr src/libcalamares/locale -ts lang/tz_en.ts + +if test -n "$XMLLINT" ; then + for f in lang/calamares_en.ts + do + $XMLLINT --format -o "$f".new "$f" && mv "$f".new "$f" + done +fi tx push --source --no-interactive -r calamares.calamares-master -tx push --source --no-interactive -r calamares.tz tx push --source --no-interactive -r calamares.fdo + ### PYTHON MODULES # # The Python tooling depends on the underlying distro to provide