-
Notifications
You must be signed in to change notification settings - Fork 12
/
update-po
executable file
·38 lines (33 loc) · 1.34 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
33
34
35
36
37
38
#!/bin/sh
# update-po -- update current .po files using .pot files.
#
# Copyright (c) 2015-2020 Boyuan Yang <073plan@gmail.com>
#
# This script is released into the Public Domain.
#
# Only a wrapper for msgmerge and msginit.
_MAN_LANG="zh_CN"
set -e
printf "%s\n" "# UPDATE-PO #######################"
for potitem in templates/*/man*/*.pot; do
i="$(printf "%s" "$(basename "${potitem}")" | sed 's/....$//')" # "....$" -> ".pot$"
echo "i is ${i}."
poitem="po/$(dirname "${potitem}" | cut -d/ -f2- )/${i}.${_MAN_LANG}.po"
rawitem="raw/$(dirname "${potitem}" | cut -d/ -f2- )/${i}"
printf "%s\n" "now poitem is ${poitem}."
mkdir -p "$(dirname "${poitem}")"
if [ -e "${poitem}" ]; then
printf "%s" "${i}"
#msgmerge -U --strict "${poitem}" "${potitem}"
#
# NO, we don't use msgmerge anymore.
# msgmerge cannot recognize comment styles, which causes problems.
# we would directly use raw file.
po4a-updatepo -f man -m "${rawitem}" -M utf8 -p "${poitem}" -o 'groff_code=translate'
else
(>&2 printf "%s does not exist, trying to create one..." "${i}.${_MAN_LANG}.po")
msginit --no-translator -i "${potitem}" -o "${poitem}" -l "${_MAN_LANG}.UTF-8"
fi
done
cd ./po; find . -name "*.po" -exec sed -i -e '/^# File:/d' {} \;
printf "%s\n" "# UPDATE-PO ### END ###############"