123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #!/bin/bash
- # Coding: utf-8
- # Editor: kate
- # Created 2022-01-30
- #_sudo_apt_install_ xclip
- #_sudo_dpkg_i_ translate-shell_0.9.6.12-1_all.deb https://pkgs.org/download/translate-shell
- source $HOME/.SCR/lib.sh
- echo ""
- if [ $# == "0" ]
- then
- arg=$(xclip -selection clipboard -o)
- echo "From clipboard: $arg"
- else
- arg="$@"
- echo "From command line: $@"
- fi
- if [ "1" == "$(echo "$arg" | wc -w)" ] # добавляем кавычка в зависимости от фраза это или слово.
- then
- text="$arg"
- echo "Word: $text"
- else
- text="\"$arg\""
- echo "Phrase: $text"
- fi
- echo ""
- echo "Select option for translate:"
- echo ""
- echo "[1] Translate to russian. Short format"
- echo "[2] Translate to english. Short format"
- echo "[3] Translate to qazaq. Short format"
- echo "[4] Translate to russian"
- echo "[5] Translate to english"
- echo "[6] Translate to qazaq"
- echo ""
- read num_choice
- case "$num_choice" in
- "1" ) result="$(trans -b -no-auto :ru "$text")" ;;
- "2" ) result="$(trans -b -no-auto :en "$text")" ;;
- "3" ) result="$(trans -b -no-auto :kk "$text")" ;;
- "4" ) result="$(trans -no-auto :ru "$text")" ;;
- "5" ) result="$(trans -no-auto :en "$text")" ;;
- "6" ) result="$(trans -no-auto :kk "$text")" ;;
- * ) fun_echo_stadia 11 0 "This item does not exist"
- exit ;;
- esac
- echo "$result"
- echo ""
- echo "If you need copy translate to clipboard press 1 and Enter"
- echo "Any other and Enter for exit"
- echo ""
- read num_choice_2
- case "$num_choice_2" in
- "1" ) echo "$result" | sed 's/\x1b\[[0-9;]*m//g' | xclip -selection c ;;
- # удаление escape-последовательностей ANSI и вывод в буфер обмена
- * ) exit ;;
- esac
|