-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
translate.sh
28 lines (25 loc) · 1 KB
/
translate.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
# Helper bash script to update and build translations files - macOS
if [[ -z "$1" ]]; then
version='0.1.9'
else
version="$1"
fi
package_name='libby-calibre-plugin'
# https://www.gnu.org/software/gettext/manual/gettext.html#xgettext-Invocation
xgettext -L Python \
--package-name="$package_name" \
--package-version="$version" \
--msgid-bugs-address='https://github.com/ping/libby-calibre-plugin/' \
--copyright-holder='ping <http://github.com/ping>' \
-o calibre-plugin/translations/default.pot calibre-plugin/*.py calibre-plugin/**/*.py
# https://www.gnu.org/software/gettext/manual/gettext.html#msgmerge-Invocation
for f in calibre-plugin/translations/*.po
do
echo "Updating ${f} from default.pot"
msgmerge --no-fuzzy-matching --update "${f}" "calibre-plugin/translations/default.pot"
sed -i'' -e "s/Project-Id-Version: .*\\\n/Project-Id-Version: ${package_name} ${version}\\\n/" $f
rm -f "${f}-e"
rm -f "${f}~"
echo "Building ${f} into ${f%\.po}.mo"
msgfmt -o "${f%\.po}.mo" "${f%\.po}"
done