Skip to content

NikitaIvanovV/dmenu-translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dmenu-translate

dmenu script for quick text translation with translate-shell

showcase

Dependencies

Installation

Manual

git clone https://github.com/NikitaIvanovV/dmenu-translate
cd dmenu-translate
sudo make install

Uninstall with sudo make uninstall

AUR

If you are an Arch Linux user, you can install dmenu-translate-git AUR package.

yay -S dmenu-translate-git

Usage

Just run dmenu-translate and the menu will appear:

  1. Enter text to translate or choose mouse text selection
  2. Select language to translate text into (or select [Define] option to view definition of a word)
  3. View translation in a new terminal window or copy it to clipboard

I bound Super-Ctrl-t to call the script on my dwm build. So, whenever I encounter a word I don't know, I can select it with a mouse and get its definition or translation very quickly. You might want to do something similar on your system.

The script respects TERMINAL and PAGER environmental variables.

You can pass addition arguments to the dmenu commands by passing them to the script like this: dmenu-translate -arg1 -arg2

Configuration

By default, only English and Russian languages appear in the menu. You can alter this behavior by editing a configuration file located at ~/.config/dmenu-translate/config.sh.

Example configuration file:

# Languages that appear in the menu.
TRANS_LANGS='ru en'

# Menu program.
DMENU='dmenu'

# Commands that are run to display menus.
DMENU_TEXT=''  # select text to translate
DMENU_LANG=''  # select language to translate to
DMENU_NEXT=''  # select what to do with the translation

# Set this to any value if you want to always copy the
# translation (skips DMENU_NEXT menu).
ALWAYS_COPY=