v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-16 07:40:44 -07:00
2023-05-16 13:44:01 +08:00
2023-02-11 14:23:07 +08:00
2023-05-16 13:44:01 +08:00
2023-01-19 12:06:20 +08:00
2023-02-11 14:23:07 +08:00
2022-10-24 23:43:20 +08:00
2023-02-09 12:36:51 +08:00
2023-03-15 21:17:25 +08:00

gtt

Google Translate TUI (Originally)

Supported Translator: Apertium, Argos, Bing, ChatGPT, DeepL (only free API), Google(default), Reverso

⚠️ Note for ChatGPT and DeepL

ChatGPT and DeepL translations require API keys, which can be obtained from OpenAI API keys and DeepL API signup pages, respectively. Note that only the free API is supported for DeepL currently. Once you have your API key add it to $XDG_CONFIG_HOME/gtt/gtt.yaml or $HOME/.config/gtt/gtt.yaml:

api_key:
    chatgpt: CHATGPT_API_KEY # <- Replace with your API Key
    deepl: DEEPL_API_KEY # <- Replace with your API Key

ScreenShot

screenshot

Install

Dependencies

For Arch Linux, you need alsa-lib. For Ubuntu or Debian, you need libasound2-dev. For RedHat-based Linux, you need alsa-lib-devel.

xclip (optional) - for Linux/X11 to copy text.

wl-clipboard (optional) - for Linux/Wayland to copy text.

Arch Linux (AUR)

yay -S gtt-bin

Prebuild

Binary file is available in Release Page for Linux and macOS on x86_64.

From source

go install

go install github.com/eeeXun/gtt@latest

And make sure $HOME/go/bin is in your $PATH

export PATH=$PATH:$HOME/go/bin

go build

git clone https://github.com/eeeXun/gtt.git && cd gtt && go build -ldflags="-s -w -X main.version=$(git describe --tags)"

Run on Docker

docker run -it eeexun/gtt

Create a theme

You can create a theme with theme name. And you must provide the color of bg, fg, gray, red, green, yellow, blue, purple, cyan, orange.

And note that:

  • bg is for background color
  • fg is for foreground color
  • gray is for selected color
  • yellow is for label color
  • orange is for KeyMap menu color

See the example in theme.yaml file. This file should located under $XDG_CONFIG_HOME/gtt/theme.yaml or $HOME/.config/gtt/theme.yaml

Language in argument

You can pass -src and -dst in argument to set source and destination language.

gtt -src "English" -dst "Chinese (Traditional)"

See available languages on:

Key Map

<C-c> Exit program.

<Esc> Toggle pop out window.

<C-j> Translate from source to destination window.

<C-s> Swap language.

<C-q> Clear all text in source of translation window.

<C-y> Copy selected text.

<C-g> Copy all text in source of translation window.

<C-r> Copy all text in destination of translation window.

<C-o> Play text to speech on source of translation window.

<C-p> Play text to speech on destination of translation window.

<C-x> Stop play sound.

<C-t> Toggle transparent.

<C-\> Toggle Definition/Example & Part of speech.

<Tab>, <S-Tab> Cycle through the pop out widget.

<1>, <2>, <3> Switch pop out window.

Credit

soimort/translate-shell, SimplyTranslate-Engines, s0ftik3/reverso-api For translation URL.

snsd0805/GoogleTranslate-TUI For inspiration.

turk/free-google-translate For Google translate in Golang.

Description
Google Translate TUI
Readme MIT 5.1 MiB
Languages
Go 99.1%
Shell 0.6%
Dockerfile 0.3%