OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / tools / po-wrap-toggle.sh
1 #!/bin/sh -e
2
3 filter_commits() {
4     # Don't include files where the only things which have changed are
5     # the creation date, the version number, the revision date,
6     # comment lines, or diff file information.
7     for f in `git diff --cached --name-only`; do
8         if [ ! -e "$f" ]; then
9             continue
10         fi
11         # It's ok if the grep fails
12         set +e
13         changed=$(git diff --cached "$f" \
14             | egrep -v "(POT-Creation-Date|Project-Id-Version|PO-Revision-Date|Last-Translator|Language-Team):" \
15             | egrep -c "^([-+][^-+#])")
16         set -e
17         if [ $changed -eq 0 ]; then
18             git reset -q "$f"
19             git checkout -- "$f"
20         fi
21     done
22 }
23
24 WRAP=1
25
26 while getopts nh OPT; do
27   case $OPT in
28     n) WRAP=0 ;;
29     h|\?)
30       echo 'Usage: $0 [-n]'
31       exit 1
32       ;;
33   esac
34 done
35
36 if [ "$WRAP" -eq 0 ]; then
37   ARGS="--no-wrap"
38 fi
39
40 set -o xtrace
41
42 cd po4a
43 for category in *; do
44   echo $category
45   cd $category/po
46   msgmerge $ARGS --previous --output ja-new.po ja.po ${category}.pot
47   mv ja-new.po ja.po
48   cd ../..
49 done
50 cd ..
51 git add po4a/
52 filter_commits
53 git reset HEAD -- po4a/