TranslatorWindows/Translater/trans.sh
Dvurechensky 971a40a028 1.0
Main
2024-10-05 10:30:49 +03:00

16 lines
605 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Пример скрипта для перевода текста с английского на русский с использованием Google Translate
text="$1"
from="en"
to="ru"
# Перевод текста
translated=$(curl -s "https://translate.googleapis.com/translate_a/single?client=gtx&sl=$from&tl=$to&dt=t&q=$(echo $text | sed 's/[[:space:]]/%20/g')")
# Извлечение переведенного текста
translated_text=$(echo "$translated" | sed 's/\[\[\[\"//' | cut -d '"' -f 1)
# Вывод переведенного текста
echo "$translated_text"