Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/tools/po_check_entry.sh
18080 views
1
#!/bin/sh
2
#
3
# Copyright (c) 2021 Fernando Apesteguia <[email protected]>
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions are met:
7
#
8
# 1. Redistributions of source code must retain the above copyright notice, this
9
# list of conditions and the following disclaimer.
10
#
11
# 2. Redistributions in binary form must reproduce the above copyright notice,
12
# this list of conditions and the following disclaimer in the documentation
13
# and/or other materials provided with the distribution.
14
#
15
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26
# Check for aspell. Everything else is in base.
27
COMMAND=aspell
28
if ! command -v ${COMMAND} >/dev/null; then
29
echo "${COMMAND} not found, please run 'pkg install aspell $your_lang-aspell'"
30
exit 1
31
fi
32
33
LANG="${1}"
34
35
if [ -z "${LANG}" ]; then
36
echo "No language specified"
37
exit 1
38
fi
39
40
translation=$(cat /dev/stdin)
41
42
# Build a grep(1) filter with all the words aspell(1) could not find in this
43
# translated text.
44
45
filter=
46
for word in $(echo "${translation}" | aspell list --lang="${LANG}");do
47
tmp=$(printf "%s" "${word}|")
48
filter="${filter}${tmp}"
49
done
50
51
filter=$(echo "${filter}" | sed -e 's/|$//g')
52
53
# Highlight the translation in the text providing the user with some context about
54
# where the reported words are used.
55
if [ -n "${filter}" ]; then
56
echo "----------- translation -----------"
57
echo "${translation}" | grep -Ew --color "${filter}"
58
echo
59
fi
60
61