GithubHelp home page GithubHelp logo

echuraev / translate-shell.vim Goto Github PK

View Code? Open in Web Editor NEW
66.0 4.0 5.0 9.84 MB

Translate-shell.vim is a plugin for translating text without leaving Vim.

License: GNU General Public License v3.0

Vim Script 99.70% Shell 0.30%
vim translate translate-shell anki anki-cards

translate-shell.vim's Introduction

translate-shell.vim

Build Status Coverage Status License

Intro

Translate-shell.vim is a plugin for translating text without leaving Vim. It provides a window that displays the translate of word under cursor, selected text or you can use "on fly" translation and translate inserted text. Also, you can save your translate story to file and import it to Anki.

translate-shell.vim screencast

FZF functions:

translate-shell.vim fzf screencast

Table of Contents

Features

The following features are supported by translate-shell.vim:

  • Translate word under cursor.
  • Translate multi line string.
  • Select direction of translate from predefined list.
  • Interactive translation.
  • Open interactive terminal with translate-shell (only Vim 8).
  • Keep translate history. Choose the better translate to save.
  • Download audio for translation.
  • Import translation history to Anki.

Requirements

The following requirements have to be met in order to be able to use translate-shell.vim:

  • Install translate-shell. Translate-shell is used as a backend for the plugin. You can find it on github.

If you would like to use FZF functions that provided by this plugin, you have to install FZF. You can find installation instruction here.

Installation

You can install translate-shell.vim by using any vim plugin manager.

Installation with vim-plug

If you doesn't have installed translate-shell in path, you can install plugin by the following command:

Plug 'echuraev/translate-shell.vim', { 'do': 'wget -O ~/.vim/trans git.io/trans && chmod +x ~/.vim/trans' }

And after it you should specify path to translate-shell by defining g:trans_bin variable e.g:

let g:trans_bin = "~/.vim"

If you already have installed translate-shell in your PATH then it is enough to install plugin by the following command:

Plug 'echuraev/translate-shell.vim'

Getting Started

Translate-shell.vim provides the following commands for translation:

  • :Trans [{options}] - Translate word under cursor.
  • :'<,'>Trans [{options}] - Translate text in visual selection.
  • :TransSelectDirection - Translate word under cursor with selecting translate direction.
  • :'<,'>TransSelectDirection - Translate text in visual selection with selecting translate direction.
  • :TransInteractive [{options}] - Translate inserted text.
  • :TransTerm [{options}] - Open terminal with interactive translate-shell. That works only in Vim 8.
  • :TransOpenHistoryWindow - Open file with translate history.
  • :TransChangeDefaultDirection - Change default direction of translating for a session.

FZF functions:

  • :FZFTransSelectDirection - Translate word under cursor with selecting translate direction.
  • :'<,'>FZFTransSelectDirection - Translate text in visual selection with selecting translate direction.
  • :FZFTransInteractive - Translate inserted text.
  • :FZFTransChangeDefaultDirection - Change default direction of translating for a session.

For more convenience, you can create key mapping for these commands e.g:

inoremap <silent> <leader>t <ESC>:Trans<CR>
nnoremap <silent> <leader>t :Trans<CR>
vnoremap <silent> <leader>t :Trans<CR>
nnoremap <silent> <leader>td :TransSelectDirection<CR>
vnoremap <silent> <leader>td :TransSelectDirection<CR>

Codes of languages you can find here or run the following command:

trans -R

For more information please look at doc/trans.txt or open Vim and run :h trans.

Import history of translating to Anki

You can add history of your translation to Anki and learn new words. Full information you can find on wiki.

TODO List

  • Keep translate story
    • Choose the better translate to save
  • Nice syntax highlighting
  • Folding for translation on multiple languages
  • Possibility to join lines for better translation
  • Refactor and join translate functions (visual and not)
  • Async downloading audio for vim 8 (may be for all system calls)
  • Limit on the size of history files

References

Author

Egor Churaev [email protected]

translate-shell.vim's People

Contributors

echuraev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

translate-shell.vim's Issues

Trans -brief doesn't respect g:trans_default_direction

:Trans :pt -brief works correctly for displaying brief Portuguese translation but simply :Trans -brief just brings the original text, despite having configured let g:trans_default_direction = ":pt". Full translation result (simply :Trans, without -brief) respects it.

List of default target languages based on determined source languages

Hi Egor,

I translate some phrases from English into Russian and from Russian into English.
And I have to use
:Trans :ru
and
:Trans :en

Is there an option to specify a list of default target languages based on determined source languages?
So I would have to use only
:Trans
command for both cases.

Unify :Trans and :TransVisual

Hi, I'm just opening this so to not forget about it and leave the suggestion behind: #3 (comment).

As commented previously, this teaches how one can check if the command is being called with a range or not: https://stackoverflow.com/a/18897835/1000282. The idea is to operate on the range if there's one, or just the word under the cursor if there's no range.

If I implement it I'll turn the issue into a pull-request, otherwise if you implement this earlier, feel free to close it :)

Feature request - floating window support

Hey, thanks for the nice plugin. ๐Ÿ‘
I would like to ask what do you think about using a floating window for :Trans? So maybe just add another option for g:trans_win_position with float? That would be awesome!

Do not open buffer if result is empty

First of all, awesome plugin. I'd like to suggest to not open the translate window if the translation result is empty, more importantly for me is because I've just installed the plugin and the first thing I tried was text-to-speech with :Trans -no-translate -speak, so I just wanted to hear audio without any text output, but despite that the translation window was open and I had to close it.

Another suggestion is to provide q as a default mapping in the translation window, for closing it. It's common that file manager plugins to do that (like vimfiler for example, Goyo also does this).

Windows10 GVim. How to use wsl shell for translate-shell.vim plugin only

Hi, and thanks for the nice plugin.

I have the same config as here
#8
Windows 10, WSL, GVIM 8, installed translate-shell.

However I can't set wsl shell globally in .vimrc file:
set shell=C:\Windows\Sysnative\wsl.exe
because another plugins use the windows cmd.exe shell.

Is it possible to specify a shell for the translate-shell.vim plugin only?
Or maybe there is another solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.