#!/bin/sh1#2# Copyright (c) 2021 Fernando Apesteguia <[email protected]>3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions are met:6#7# 1. Redistributions of source code must retain the above copyright notice, this8# list of conditions and the following disclaimer.9#10# 2. Redistributions in binary form must reproduce the above copyright notice,11# this list of conditions and the following disclaimer in the documentation12# and/or other materials provided with the distribution.13#14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE17# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR20# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER21# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE23# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2425# Check for aspell. Everything else is in base.26COMMAND=aspell27if ! command -v ${COMMAND} >/dev/null; then28echo "${COMMAND} not found, please run 'pkg install aspell $your_lang-aspell'"29exit 130fi3132LANG="${1}"3334if [ -z "${LANG}" ]; then35echo "No language specified"36exit 137fi3839translation=$(cat /dev/stdin)4041# Build a grep(1) filter with all the words aspell(1) could not find in this42# translated text.4344filter=45for word in $(echo "${translation}" | aspell list --lang="${LANG}");do46tmp=$(printf "%s" "${word}|")47filter="${filter}${tmp}"48done4950filter=$(echo "${filter}" | sed -e 's/|$//g')5152# Highlight the translation in the text providing the user with some context about53# where the reported words are used.54if [ -n "${filter}" ]; then55echo "----------- translation -----------"56echo "${translation}" | grep -Ew --color "${filter}"57echo58fi596061