-
Notifications
You must be signed in to change notification settings - Fork 1
/
trans.sh
80 lines (69 loc) · 1.42 KB
/
trans.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
TRANSIFEX_BASE=/home/matt/habari/transifex/
TRANSIFEX_TS=/home/matt/habari/transifex/translations/habari.systemhead/
GIT=/home/matt/habari/habari-locales/
GIT_CRED=`cat /home/matt/habari-locales.userpass`
function github_create
{
curl -f -u $GIT_CRED https://api.github.com/orgs/habari-locales/repos -d '{"name":"'$1'"}'
}
function github_clone
{
git clone [email protected]:habari-locales/$1.git
}
function github_init
{
mkdir $1
mkdir $1/LC_MESSAGES
cd $1
touch README.md
git init
git add README.md
git commit -m "intialize repo"
git remote add origin [email protected]:habari-locales/$1.git
git push -u origin master
cd ..
}
function github_pull
{
cd $1
git pull
cd ..
}
function github_push
{
echo "moving $1.po"
cd $1
cp $TRANSIFEX_TS$1.po LC_MESSAGES/habari.po
echo "generating mo file"
msgfmt -o LC_MESSAGES/habari.mo LC_MESSAGES/habari.po
git add LC_MESSAGES/habari.po LC_MESSAGES/habari.mo
echo "committing to github"
git commit -a -m"transifex sync"
git push
cd ../
}
# update transifex files
cd $TRANSIFEX_BASE;
tx pull;
# check fo .po
cd $GIT;
for d in `ls $TRANSIFEX_TS*.po`;
do
if [[ $d =~ $TRANSIFEX_TS(.*).po ]]
then
if [ ! -d ${BASH_REMATCH[1]} ]
then
if ! github_create ${BASH_REMATCH[1]}
then
github_clone ${BASH_REMATCH[1]}
else
github_init ${BASH_REMATCH[1]}
fi
else
github_pull ${BASH_REMATCH[1]}
fi
github_push ${BASH_REMATCH[1]}
fi
done
echo "done!"