Skip to content
Snippets Groups Projects
refresh-translations 4.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • PERL_PROGS="/usr/local/bin/tails-security-check \
    
    anonym's avatar
    anonym committed
        /usr/local/lib/tails-htp-notify-user \
        /usr/local/lib/tails-virt-notify-user"
    
    PYTHON_PROGS="/etc/whisperback/config.py \
    
    anonym's avatar
    anonym committed
        /usr/local/bin/electrum \
    
        /usr/local/bin/tails-about \
        /usr/local/bin/tails-screen-locker \
    
        /usr/local/bin/tails-upgrade-frontend-wrapper \
    
        /usr/local/sbin/tails-additional-software"
    
    SHELL_PROGS="/etc/NetworkManager/dispatcher.d/60-tor-ready.sh \
    
    anonym's avatar
    anonym committed
        /usr/local/bin/keepassx \
        /usr/local/lib/tails-spoof-mac \
        /usr/local/bin/tor-browser \
        /usr/local/sbin/unsafe-browser"
    
        /usr/share/gnome-shell/extensions/status-menu-helper@tails.boum.org/extension.js \
    
    anonym's avatar
    anonym committed
        /usr/share/gnome-shell/extensions/torstatus@tails.boum.org/extension.js \
    
    
    LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
    
    
    anonym's avatar
    anonym committed
    . config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh
    
    . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
    
    
    normalize_pot () {
    
        sed --regexp-extended \
            -i 's@^"Content-Type: text/plain; charset=CHARSET\\n"@"Content-Type: text/plain; charset=UTF-8\\n"@' \
            "${@}"
    
    anonym's avatar
    anonym committed
        prog=$1
    
        progpath="config/chroot_local-includes$prog"
        case $prog in
    
            /usr/share/gnome-shell/extensions/status-menu-helper@tails.boum.org/extension.js)
                domain=status-menu-helper-extension.js
    
    anonym's avatar
    anonym committed
                ;;
            *)
                domain=$(basename $prog)
                ;;
        esac
        echo "tmp/pot/${domain}.pot"
    
    anonym's avatar
    anonym committed
        prog=$1
        proglang=$2
        progpath="config/chroot_local-includes${prog}"
        if [ -e "${progpath}" ]; then
            pot="$(prog_potfile "${prog}")"
            mkdir -p "$(dirname ${pot})"
            xgettext --language="${proglang}" --from-code=UTF-8 \
                     -o "${pot}" "${progpath}"
            normalize_pot "${pot}"
        else
            echo "error: We are supposed to create a POT file for '${prog}'" \
                 "but '${progpath}' does not exist"
            exit 1
        fi
    
    po_file () {
    
    anonym's avatar
    anonym committed
        locale=$1
    
    anonym's avatar
    anonym committed
        echo "po/${locale}.po"
    
    anonym's avatar
    anonym committed
        locale=$1
    
    anonym's avatar
    anonym committed
        echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
    
    anonym's avatar
    anonym committed
        for locale in "$@" ; do
            po=$(po_file $locale)
            mo=$(mo_file $locale)
            mkdir -p $(dirname "$mo")
            msgfmt -o "${mo}" "${po}"
        done
    
    anonym's avatar
    anonym committed
        (cd po && intltool-update --maintain)
        [ ! -e po/missing ] || return 1
        return 0
    
    anonym's avatar
    anonym committed
        (
            cd po
            cp -a tails.pot tails.pot.orig
            intltool-update --pot --gettext-package=tails
            normalize_pot tails.pot tails.pot.orig
    
    
            if [ "${FORCE:-}" = yes ]; then
    
    anonym's avatar
    anonym committed
                echo "Force-updating 'tails.pot'."
                rm tails.pot.orig
    
            elif diff_without_pot_creation_date_and_comments -q tails.pot.orig tails.pot; then
    
    anonym's avatar
    anonym committed
                echo "Only header or comment changes in tails.pot: keeping the old one"
                mv tails.pot.orig tails.pot
            else
                echo "Real changes in tails.pot: switching to the updated one"
                rm tails.pot.orig
            fi
        )
    
    anonym's avatar
    anonym committed
        extract_from_file_between_markers po/POTFILES.in \
            '^# Files updated by intltool-update --desktop-style' '^$' \
    
    anonym's avatar
    anonym committed
            | while read infile ; do
                  intltool-merge --quiet --desktop-style --utf8 \
                                 po "$infile" "${infile%.in}"
              done
    
    anonym's avatar
    anonym committed
        extract_from_file_between_markers po/POTFILES.in \
            '^# Files updated by intltool-update --xml-style' '^$' \
    
            | while read infile ; do
                  intltool-merge --quiet --xml-style --utf8 \
                                 po "$infile" "${infile%.in}"
              done
    }
    
    
    FORCE=no
    
    while [ -n "${@:-}" ]; do
        case "${1:-}" in
            '--force')
                FORCE=yes
                ;;
    
            *)
                echo "Unknown option: ${1}"
                exit 1
                ;;
        esac
        shift
    done
    
    
    # Schedule clean up
    trap "rm -fr po/*.new po/*.orig ; [ "$KEEP_TMP_POT" = yes ] || rm -fr tmp/pot" EXIT
    
    
    for prog in $PERL_PROGS   ; do create_pot $prog Perl   ; done
    for prog in $PYTHON_PROGS ; do create_pot $prog Python ; done
    for prog in $SHELL_PROGS  ; do create_pot $prog Shell  ; done
    for prog in $JAVASCRIPT_PROGS  ; do create_pot $prog JavaScript ; done
    
    # If left out files are detected, intltool-update --maintain writes
    # them to po/missing.
    no_left_out_files || exit 3
    
    
    # Update files that are actually used at runtime
    
    intltool_merge_desktop
    intltool_merge_xml
    
    chmod +x config/chroot_local-includes/etc/skel/Desktop/*.desktop