File: translate-desktop.sh

package info (click to toggle)
neverball 1.5.4-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 94,644 kB
  • sloc: ansic: 22,125; makefile: 438; sh: 150; xml: 129; awk: 69
file content (26 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# This script reads a .desktop file from stdin and prints the same file, with
# up-to-date translations, to stdout.

while read line; do
    # Remove translations
    if echo $line | grep '^.*\[.*\]=' > /dev/null; then
        continue
    fi

    echo $line

    # Generate translations if current line is translatable
    if echo $line | grep '^Comment=' > /dev/null; then
        msgid=`echo $line | sed 's/^Comment=//'`
        for i in po/*.po; do
            lang=`basename $i | sed 's/\.po//'`
            msgstr=`msgattrib --translated --no-obsolete --no-fuzzy $i \
                    | msggrep --no-location --no-wrap --msgid -F -e "$msgid" \
                    | tail -n 1 | sed 's/^msgstr "\(.*\)"$/\1/'`
            if [ "$msgstr" != "" ]; then
                echo "Comment[$lang]=$msgstr"
            fi
        done
    fi
done