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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#!/bin/bash
# AUTHOR: Omar Campagne, ocampagne at gmail dot com
#### Follow this steps to get the whole gmpc l10n thing under dir A
# mkdir A && cd A && git clone elric/gmpc.git && mv gmpc gmpc-l10n && cd gmpc-l10n && ./update-lp.sh -u
####### ALERT !!!! #######
## rename this repo dir (gmpc) as gmpc-l10n before running
## the script, or use the command above
### this script creates/expects the following dir tree, and to be
### used from elric/gmpc.git repository.
#/parent
# /gmpc-l10n/script (this repo), you should run the script
# from this folder
# /l10nexport (LP's) translations
# /gmpc < -- main
# /gmpc-$plugin
### DONE:
### Git to LP TRY MERGE LOCAL FILES
## Pull/clone from git -> Create/update POT and PO -> copy to elric/gmpc.git -> commit and push,
## indirectly to LP
## Download from bzr, upload to git
### Set here the name of the plugins/git repos (gmpc-$plugin.git) to manage,
## manpages is independent, works with po4a. Main gmpc POT is not automatically
## created for now.
plugins="alarm discogs last.fm lyricwiki shout lyricsplugin mdcover tagedit "
cd ../
update_po () {
# [1] Pulls updates if repo is present, otherwise, clone
for plugin in $plugins ; do
if [ -d gmpc-$plugin ] ; then
cd gmpc-$plugin
echo "Updating gmpc-$plugin"
git pull
cd ..
else
git clone git://git.musicpd.org/qball/gmpc-$plugin.git ;
fi
done
# [2] Create POT and update PO files
echo "Updating po files..."
for plugin in $plugins ; do
shopt -s nullglob
cd gmpc-$plugin/po
intltool-update -p
cd ../../
done
## [3] Copy POT to l10n git branch
cd gmpc-l10n
echo "Moving POTs to l10n branch"
for plugin in $plugins ; do
mkdir -p $plugin/
mv ../gmpc-$plugin/po/*.pot $plugin/ # git pull from local repo doesn't seem to work
git add $plugin # In case it doesn't exist
done
cd ..
### Manpages with po4a
if [ ! -d gmpc ] ; then
git clone git://git.musicpd.org/qball/gmpc.git
cp gmpc/doc/gmpc.1 gmpc-l10n/gmpc-manpage/
cd gmpc-l10n/gmpc-manpage/
po4a po4a.cfg
rm gmpc.1
cd ..
else
cp gmpc/doc/gmpc.1 gmpc-l10n/gmpc-manpage/
cd gmpc-l10n/gmpc-manpage/
po4a po4a.cfg
rm gmpc.1
cd ..
fi
## [4] Update l10n branch (elric/gmpc.git) that syncs to LP
# One commit per plugin -> l10n "item"
for plugin in $plugins ; do
cd $plugin/
git commit *.pot -m "$plugin updated"
cd ..
done
cd gmpc-manpage/po
git commit -a -m "manpage updated"
cd ../../
git push origin master
}
#### This function downloads the translation from LP
## and commits them to each git repository
bzr_download () {
if [ -d l10nexport ] ; then
cd l10nexport
echo "Fetching new revsions in LP"
bzr update
cd ..
else
echo "Downloading branch...."
bzr branch lp:~gmpc-developers/gmpc/l10nexport
fi
### Plugins update LP2git
cd l10nexport
for plugin in $plugins; do
cd $plugin
echo "Copying PO files to git repos"
for file in . ; do
cp -r $file ../../gmpc-$plugin/po/ ;
done
cd ..
done
cd ..
for plugin in $plugins ; do
cd gmpc-$plugin
git commit -a "$plugin translations updated"
git push origin master
cd ..
done
}
### Manpages update
### Do be done when it is decided how to distribute the translations
### Messages update
help_message () {
echo "$0 [option]"
echo "-h This message"
echo "-u, --update Full update process, from downloading/updating the po files in git "
echo " to making them available in LP after the bzr sync"
echo "-d, --download For now, only downloads/updates the bzr branch with"
echo " LP translations. + alias than function"
}
if [ ! -n "$1" ] ; then # Show usage if no parameter is given
help_message
exit 1
else
case $1 in
-u|--update) update_po;;
-d|--download) bzr_download;;
-h|--help) help_message;;
-*|--*) echo "The option '$1' doesn't exist";;
esac
fi
|