Skip to content

Instantly share code, notes, and snippets.

@koumaza
Last active May 26, 2020
Embed
What would you like to do?
Translate in Terminal

TiT (Translate in Terminal)

This page: https://git.io/TiT

using translate google;
  • En to Ja

curl -sL https://gist.github.com/koumaza/6026efd35025a7b634f8b8e47c43f5f6/raw/c14e39d34193f0ffdc893c97c65b9691a7c2bf9c/en2ja.fish.sh|env argv=hello HOME=/tmp fish

  • Ja to En

curl -sL https://gist.github.com/koumaza/6026efd35025a7b634f8b8e47c43f5f6/raw/c14e39d34193f0ffdc893c97c65b9691a7c2bf9c/ja2en.fish.sh|env argv="こんにちは" HOME=/tmp fish

Register function

If you want to register a feature, We recommend that you subscribe to receive notifications of fixes and more.

  • En to Ja
function en2ja
  curl -sL https://gist.github.com/koumaza/6026efd35025a7b634f8b8e47c43f5f6/raw/c14e39d34193f0ffdc893c97c65b9691a7c2bf9c/en2ja.fish.sh|env argv=$argv HOME=/tmp fish
end
function en2ja-int
  while true
    read intr -p "echo '|En |> Ja| :>> '"
    if test "$intr" = break
      break
    else if test "$intr" = exit
      break
    end
    en2ja $intr
  end
end
  • En to Ja
function ja2en
  curl -sL https://gist.github.com/koumaza/6026efd35025a7b634f8b8e47c43f5f6/raw/c14e39d34193f0ffdc893c97c65b9691a7c2bf9c/ja2en.fish.sh|env argv=$argv HOME=/tmp fish
end
function ja2en-int
  while true
    read intr -p "echo '|Ja |> En| :>> '"
    if test "$intr" = break
      break
    else if test "$intr" = exit
      break
    end
    ja2en $intr
  end
end
#!/usr/bin/fish
set source_lang en
set target_lang ja
function url_encode
perl -pe 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'
end
set script_url "https://script.google.com/macros/s/AKfycbzZtvOvf14TaMdRIYzocRcf3mktzGgXvlFvyczo"
set text (echo "$argv"|url_encode)
echo -e (curl -sL ""$script_url"/exec?text="$text"&source="$source_lang"&target="$target_lang""|jq .text) | tr -d '\n''\"'
#!/usr/bin/fish
set source_lang ja
set target_lang en
function url_encode
perl -pe 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg'
end
set script_url "https://script.google.com/macros/s/AKfycbzZtvOvf14TaMdRIYzocRcf3mktzGgXvlFvyczo"
set text (echo "$argv"|url_encode)
echo -e (curl -sL ""$script_url"/exec?text="$text"&source="$source_lang"&target="$target_lang""|jq .text) | tr -d '\n''\"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment