blob: 1c228053071b38995a5fcc0773504d57b9bf9619 (
plain)
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
|
#!/bin/bash
set -e -u
case $# in
1) SRC=en
WORD="$1"
;;
2) SRC="$1"
WORD="$2"
;;
*) echo "Usage: $0 word_in_English"
echo " or"
echo " $0 language_code word_in_given_language"
exit 1
;;
esac
LANGUAGES=( en ar cs da de el es fi fr he hu id it ja ko nb nl pl pt ro ru sk sv sw th tr uk vi zh-CN zh-TW )
for lang in "${LANGUAGES[@]}"; do
TRANSLATION=$(trans -b "$SRC:$lang" "$WORD" | sed 's/ *//')
# Use our categories.txt names for Chinese.
if [[ $lang == "zh-CN" ]]; then
lang="zh-Hans";
elif [[ $lang == "zh-TW" ]]; then
lang="zh-Hant";
fi
echo "$lang:$(tr '[:lower:]' '[:upper:]' <<< ${TRANSLATION:0:1})${TRANSLATION:1}"
done
|