Command line tool for word translations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lio Novelli 70a07d6ae3 Found issue with references. 2 years ago
test Found issue with references. 2 years ago Add no color option (can be set as default variable). 3 years ago Found issue with references. 2 years ago



There was no nice command line tool for translations to be found so I've written my own. I was frustrated by opening a new tab in browser whenever I wasn't able to remember a translation of a word. I use terminal a lot and ponsapi-cli is one of the micro optimisations that at the end of the day sum up (I hope).

I gave a lot of attention to pretty printing results, but not so much care was spent to make the translation script fast. It is something that will be addressed in the future versions but until then all you get is "pretty printing".


trans [flags] <word>

To get help use flag -h.

-f option (fuzzy matching) helps if no results were found.


This script uses following tools:

  • curl
  • jq
  • recode
  • sed


First you have to register at api registration form.

Once you get your API secret key, create a file named ponsapi.config in one of these paths: $HOME, $HOME/.config or $HOME/.config/ponsapi-cli.

Besides PONS_SECRET="<your-pons-secret>" line in your config file, you can specify other default parameters there as well (PONS_DICT for dictionary - you can see a list of those by calling trans script with flag -o and PONS_LANG to specify in which language is the word you are looking translation for).

Make your script executable and crate a symlink to it in your execution path. Simplier solution is to just a create alias in your .bashrc/.zshrc file (alias trans="<path-to-script>/")

How it works

Script creates a curl request to pons api and parses json response with jq. Json response can have 2 different structures depending on a results found in their dictionary. This complicates parsing a little bit but script has two functions written for parsing each of those two different structures and creates a unified json which is then used for pretty printing results.

You can see raw results with -r flag.


I will rewrite this application in haskell once I found more time. Even before that I'll implement some error handling.

to do

  • error handling
  • rewrite into haskell


  • no color option