-
Notifications
You must be signed in to change notification settings - Fork 4
/
create-pot-file.sh
executable file
·107 lines (90 loc) · 2.75 KB
/
create-pot-file.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
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
#!/bin/sh
if ! command -v mdview >/dev/null; then
echo >&2 "${0%%*/}: error: This script needs command 'mdview'."
exit 1
fi
VERSION=2.0.0
DMD=../../findnrun
DBIN=../../../../bin
FPOT=findnrun.new.pot
FINAL=findnrun.pot
ERRORS=
create_pot_file() # {{{1
{
local f
set +f
rm -f "${FPOT}.tmp"
xgettext -o "${FPOT}.tmp" -ci18n -L Shell --no-wrap \
--package-name=find-n-run --package-version=${VERSION} \
--msgid-bugs-address=https://github.com/step-/find-n-run/issues/ \
"${DBIN}/findnrun" || {
ERRORS="${ERRORS}
xgettext"; return 1; }
sed -i '
1,20{s/SOME DESCRIPTIVE TITLE/Findnrun '"${VERSION}"'/}
1,20{s/YEAR THE PACKAGE.*$/2015-2016 step; 2015 FSH, L18L, step/}
1,20{s/FIRST AUTHOR.*$/step, 2015 https:\/\/github.com\/step-\//}
1,20{s/CHARSET/UTF-8/}
/POT-Creation-Date:/{s/[0-9][0-9][0-9][0-9]\\n/0000\\n/}
1,20{s/Language: /&English/}
$ a \
\
# =======================================================================\
# i18n User documentation in markdown format from .md files follows.\
# i18n IMPORTANT! Reproduce indentation and special punctuation exactly.\
# =======================================================================\
' "${FPOT}.tmp" || {
ERRORS="${ERRORS}
sed"; return 1; }
for f in "${DMD}/"*.md "${DMD}/../examples/"*/*.md; do
case $f in
*/TRANSLATING.md)
: >&2 $f targets translators - they need English doc only
;;
*/plugin-debugging.md|*/plugin-dev.md|*/plugin-examples.md|*/plugin-list.md)
: >&2 $f targets developers - they prefer English doc anyway
;;
*/no-help.md)
: >&2 $f is obsolete
;;
*/examples/*)
: >&2 $f not now - maybe to be translated in a future release
;;
*/LICENSE.md) : >&2 we keep $f in English as GNU GPL does not endorse translations
;;
*)
: >&2 $f target end users - translate it
echo >&2 "$f"
echo "
# ---------------------------------------------------------
# i18n $f
# ---------------------------------------------------------
"
if [ LICENSE.md = "$f" ]; then # NOT REACHED
echo "
# i18n LICENSE.md is a special case. Do not try to translate it. Instead
# i18n find a translation from http://www.gnu.org/licenses/translations.html
# i18n and use that translated text here.
"
fi &&
mdview --po "$f" || ERRORS="${ERRORS}
mdview '$f'"
# Sometimes mdview returns error status but prints no error message.
;;
esac
done >> "${FPOT}.tmp"
msguniq --no-wrap -o "${FPOT}.2.tmp" "${FPOT}.tmp" || ERRORS="${ERRORS}
msguniq"
sed '
/#-#-#-#-#/d
s|^#: ../../../../|#: /usr/|
s/^#:.*find-n-run/#: /
' "${FPOT}.2.tmp" || ERRORS="${ERRORS}
sed 2"
rm -f "${FPOT}."*tmp
return ${ERRORS:+1}
}
# {{{1}}}
create_pot_file > "${FPOT}"
[ -n "${ERRORS}" ] && echo >&2 "${0##*/}: ERRORS:${ERRORS}"
exit ${ERRORS:+1}