Skip to content

Commit 102128c

Browse files
committed
abpoutil: fix several bugs
- Remove quotes in langs=() at new_lang. - Use correct parameter when creating a new PO file. - Correct msgupdate to msgmerge. - Always start over when creating or updating PO templates.
1 parent 0064451 commit 102128c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

contrib/abpoutil

+11-6
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ create_lang() {
154154
echo "ERROR: Invalid usage: Language code required." >&2
155155
return 1
156156
fi
157-
langcodes=("$(locale -a | sed 's|\..*||g' | sort | uniq)")
157+
langcodes=($(locale -a | sed 's|\..*||g' | sort | uniq))
158158
for l in "${langcodes[@]}" ; do
159-
if [ "x$l" = "x$lang" ] ; then
159+
if [ "x$l" = "x$newlang" ] ; then
160160
has_lang=1
161161
fi
162162
done
@@ -167,7 +167,7 @@ create_lang() {
167167
fi
168168
echo "-- Creating untranslated PO file for $newlang ..."
169169
msginit -i "$po_dir"/"$GETTEXT_DOMAIN.pot" -o "$po_dir"/"$newlang".po \
170-
--language "${newlang%%.*}.UTF-8"
170+
--locale "${newlang%%.*}.UTF-8"
171171
msgfmt --statistics -o /dev/null "$po_dir"/"$newlang".po
172172
echo "-- Succeffully initialized PO file at $po_dir/$newlang.po."
173173
}
@@ -180,6 +180,7 @@ generate_pot() {
180180
exit 1
181181
fi
182182
echo "-- Creating PO template for maintscripts of $PKGNAME ..."
183+
mkdir "$po_dir"
183184
pushd "$ab_dir"
184185
# If it contains several sources, generate them one by one,
185186
# then concatenate them together using msgcat.
@@ -207,6 +208,10 @@ generate_pot() {
207208
update_po() {
208209
echo "-- Updating PO template ..."
209210
pushd "$ab_dir"
211+
if [ -e "$po_dir"/"$GETTEXT_DOMAIN.pot" ]; then
212+
rm "$po_dir"/"$GETTEXT_DOMAIN.pot"
213+
fi
214+
touch "$po_dir"/"$GETTEXT_DOMAIN.pot"
210215
for src in "${GETTEXT_SRCS[@]}" ; do
211216
_var="$(transform_varname "${src##*/}")"
212217
_var="GETTEXT_SRCLANG_$src"
@@ -225,10 +230,10 @@ update_po() {
225230
done
226231
popd
227232
echo "-- Updating PO catalogs ..."
228-
for lang in "${GETTEXT_LINUGAS[@]}" ; do
229-
# NOTE: msgupdate -U def.po ref.pot
233+
for lang in "${GETTEXT_LINGUAS[@]}" ; do
234+
# NOTE: msgmerge -U def.po ref.pot
230235
# NOTE: make sure po files are newer than the POT file
231-
msgupdate -U "$po_dir"/"$lang".po \
236+
msgmerge -U "$po_dir"/"$lang".po \
232237
"$po_dir"/"$GETTEXT_DOMAIN".pot
233238
touch "$po_dir"/"$lang".po
234239
done

0 commit comments

Comments
 (0)