/rofitr

Translate text using rofi.

Primary LanguageShellGNU General Public License v3.0GPL-3.0

rofitr

A bash script to translate text using rofi.

rofitr

Usage

Translation
InputDescription
en:es textOverride default SOURCE and TARGET
:en textAuto-detect SOURCE; translate into English
textTranslate with defaults
Actions
KeywordDescription
!e wordshow examples for "word"
!s textspeak the "text"
!!show last translation
!!eshow examples for last translation
!!sspeak last translation
!select and translate from history
!dselect and delete from history
!ddclear history (in delete mode)
?display usage

Command line:

  • Launch rofitr:
$ rofitr
  • Translate into Russian:
$ rofitr :ru text
  • Translate from primary selection (clipboard):
$ rofitr -s

Requirements

Configuration

Edit script to change default translation options or pass them from command line:

SOURCE=en TARGET=ru rofitr

Following options are configurable:

## Set defaults
# SOURCE="en"               # source language code
# TARGET="es"               # translation language code
# ENGINE="google"           # google, yandex or bing
# LOCALE="en"               # translator language ($LANG var. by default)
# SPEAK_SOURCE="false"      # speak the source (true/false)
# SPEAK_TRANSLATION="false" # speak the translation (true/false)

## Rofi general options
# leave these empty or comment out to use system defaults:
FONT="mono 10"
WIDTH="60"
LOCATION="2"
YOFFSET="20"

# use alternative config and theme
# CONFIG="~/.config/rofi/translate-config.rasi"
# THEME="/usr/share/rofi/themes/lb.rasi"

## Rofi required options
HIST_LINES="15" # lines to show for history mode
RES_LINES="42"  # limit output to screen height
PROMPT_TR=" translate"
PROMPT_HIST=" history"
PROMPT_DEL=" delete"
CLR_RESULT="#ebdbb2" # text color for translation
CLR1="#b8bb26"
CLR2="#1d2021"