-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate-po
executable file
·33 lines (27 loc) · 1.03 KB
/
update-po
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
#!/bin/bash
#
# To generate a .pot (translation template) file from POTFILES.in:
# > xgettext --output=messages.pot --files-from=po/POTFILES.in
#
# To generate a .po (translation file) from the .pot template:
# > msginit --input=po/messages.pot --output-file=po/es.po --locale=es
#
# To update an existing .po translation file from the .pot template:
# > msgmerge --update po/es.po po/messages.pot
#
# TODO: move ./po -> ./languages
PO_DIR=./po
PLUGIN_INPUT=system/sdprompt-viewer.plugin.desktop.in
COMMAND="$1"
LOCALE="$2"
xgettext --language=Desktop --keyword=Description --output="$PO_DIR/messages.pot" "$PLUGIN_INPUT"
xgettext -join-existing --keyword=_ --output="$PO_DIR/messages.pot" --files-from="$PO_DIR/POTFILES.in"
if [[ $COMMAND == 'create' ]]; then
[[ -z "$LOCALE" ]] && echo "locale missing" && exit 1
msginit --input="$PO_DIR/messages.pot" --output-file="$PO_DIR/$LOCALE.po" --locale=$LOCALE
else
for file in "$PO_DIR"/*.po; do
msgmerge --update "$file" "$PO_DIR/messages.pot"
done
fi
rm "$PO_DIR/messages.pot"