po.sh 1.23 KB
Newer Older
1
2
3
# This shell library is meant to be used with `set -e` and `set -u`.

po_languages () {
anonym's avatar
anonym committed
4
5
6
7
    for po in po/*.po ; do
        rel="${po%.po}"
        echo "${rel#po/}"
    done
8
9
}

10
diff_without_pot_creation_date () {
anonym's avatar
anonym committed
11
    diff --ignore-matching-lines '^"POT-Creation-Date:' "${@}"
12
13
}

anonym's avatar
anonym committed
14
15
16
diff_without_pot_creation_date_and_comments () {
    diff --ignore-matching-lines '^"POT-Creation-Date:' \
         --ignore-matching-lines '^#: .*:[0-9]\+$' "${@}"
17
18
}

19
intltool_update_po () {
anonym's avatar
anonym committed
20
    (
21
22
23
        cd po
        for locale in "$@" ; do
            intltool-update --dist --gettext-package=tails $locale -o ${locale}.po.new
24

25
26
27
            [ -f ${locale}.po ]     || continue
            [ -f ${locale}.po.new ] || continue

28
29
30
            if [ "${FORCE}" = yes ]; then
                echo "Force-updating '${locale}.po'."
                mv ${locale}.po.new ${locale}.po
31
            elif diff_without_pot_creation_date -q "${locale}.po" "${locale}.po.new"; then
anonym's avatar
anonym committed
32
33
                echo "${locale}: Only header changes in PO file: keeping the old one"
                rm ${locale}.po.new
34
            else
anonym's avatar
anonym committed
35
                echo "${locale}: Real changes in PO file: switching to the updated one"
36
                mv ${locale}.po.new ${locale}.po
37
            fi
38
        done
39
    )
40
}