Release 0.2.3 or, Pivoting- by a beautiful little fool
Tags: opensource, javascript, startrek, github
Published: 2020-10-24 04:15:41

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3imd479aiqhqouqkfg4a.jpg)

My life is the great Canadian tragedy. 

You see, in my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. Whenever you feel like criticizing anyone, he told me, just remember that all the people in this world haven't had to start working on front end testing with Gatsby only to be told three days before a due date that we're switching to Next.JS, thus pausing all progress made... GASPby!

For the last week I've been slowly but surely researching tech like React/Gatsby, Jest & Enzyme, and the React Testing Library in preparation to make my modest contribution of some front end tests for [Seneca College's Telescope project](https://github.com/Seneca-CDOT/telescope). Telescope is made by students from my OSD600 class, as lead by our benevolent dictator for life, the one and only Humph. This small contribution is part of my month long assignment (see: Hacktoberfest) to make four pull requests to any open source project. This was to be the third. And yet, it was not meant to be. At least for now.

I, however, did thoroughly enjoy the time I spent researching, talking, and joking around with Calvin, Josue, and my partner in crime with this act; [Tony](https://tonyknvu.medium.com/). But it did leave me in a bind. Enter, plan B.

___

About 8 or 9 days ago I noticed a post on reddit's /r/firefox titled: [A dictionary extension better than Google's and on both Firefox and Chrome](https://old.reddit.com/r/firefox/comments/jbo789/a_dictionary_extension_better_than_googles_and_on/). I'm always down to try new toys so I looked into it. Turns out it's open source, written in Coffeescript, a language I've been interested in for a few years now. Neat! Why would I not want to play around with it? What else am I going to do? Grow cumin? It's actually pretty slick and well made, if anyone is looking for a good dictionary extension or has an interest in learning a new language I highly recommend it.

So naturally I thought to [add a Klingon translation](https://github.com/revir/dictionaries/issues/20). [Shut up, it's not weird.](https://www.youtube.com/watch?v=mgPy2kU9nEk)

My first instinct was to search for a translator that supported [Klingonese](https://en.wikipedia.org/wiki/Klingon_language). There's [actually](https://www.bing.com/translator) [a](https://tradukka.com/translate/en/tlh) [few](https://www.translator.eu/english/klingon/translation/), but none that I found had an API I could exploit. Then I found the [Klingon Pocket Dictionary](http://klingonska.org/dict/) which had an open URL query string, great! Their database is actually open too. I thought of scraping only the translations to add a small sqlite database with a couple of functions but felt that was a bit excessive for something as silly as this, maybe one day I'll get around to it and build a small API around it for fun.

There's actually people who speak Klingon too, and have [varying](https://old.reddit.com/r/startrek/comments/25ptyf/klingon_translator/) [opinions on translators](https://old.reddit.com/r/startrek/comments/1lyae3/accurate_klingon_translation/), [and even](https://old.reddit.com/r/tlhInganHol/) [services to translate things for you](https://old.reddit.com/r/startrek/comments/2odlj6/request_klingon_translator/). Isn't that awesome? After all, why the hell not?

Anyway. Revir Yang, the project creator, has [documentation](https://github.com/revir/dictionaries/blob/master/more-dicts.md) on how to add dictionaries to his project. I forked it, cloned it, and researched how to properly run and build a node app, then realized his main page actually [says how to](https://github.com/revir/dictionaries#build) at the bottom. I figured the process was different somehow because it was generating a browser extension, something of which I have no idea how it works. Turns out browser extensions are actually just made in HTML, CSS, and JavaScript. Neat eh? I had no idea, and it's only natural too I suppose. Plus CoffeeScript actually compiles to JavaScript which is even cooler. I quickly added the translation website to the API and then I just had to point Firefox to the build directory... which it didn't like for some reason, so off to Edge I went, which did like it. Go figure.

From there it was just a process of figuring out how to actually add the new dictionary to the now built extension, as just adding the API was not enough:

```JS
addExtraDict (
    {
        dictName: 'Klingon', 
        windowUrl: 'http://klingonska.org/dict/?q=<word>', 
        css: '#searchform,#top_nav {display: none;}'
    }
)
```

Once that was done everything worked as expected. You click on a word and it'll define and dictate the word in English by default, but if you right click "look up `word` in dictionaries" it'll give you the full list of translators available which will bring up their respective site upon click.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pe2jj44y50ghhbcnhaf2.png)

Finally, my last task was to add custom CSS to run upon each successive translation sent to the Klingon pocket dictionary website. Personally, I'd rather have left this step out but all the other additional dictionaries added had it, and I felt like this already small PR just wasn't enough by itself, so I decided to research how I could hide everything except the necessary details for the translation page. I searched around using Firefox's dev tools to find the element (`<section>`) I just wanted and worked around it. This was by far the longest process in the PR and made me realize how little I actually remember from my intro to web development class, though it was enough to let me google my way to victory via [stack overflow](https://stackoverflow.com/questions/1511745/hide-all-elements-excep-one-div-for-print-view).

I saved a local copy of the translation page and played around with it in VSCodium and Live Server until I was happy with the results which you can see a before and after picture of below. Also, turns out the site's HTML and CSS is obfuscated/minified so uh... thank Kahless for Prettier.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/75wee6o0thfgkvl53njv.gif)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xe5lgkfp4moh51sgn6hs.png)

And that was about it. [I submitted my PR](https://github.com/revir/dictionaries/pull/23) and await his response. He seems like a cool guy, he's from Wuhan, China actually. I'm sure he has some stories to tell. I've always wanted to go to China so maybe one day.

I know this PR was considerably smaller than [my previous one](https://github.com/mjswensen/shoulders/pull/8/commits/60474275202dddae394a217be78f95c44a4b0df9), but I weirdly feel like I learned more from this meager PR than I did from the previous one. I learned a little about CoffeeScript, node, browser extensions- not to mention what I looked into before hand about the front end testing.

I guess the tl;dr is I made some new friends, got in some research, had a fun nerd moment, and feel overall excited about [whatever is next](https://github.com/nasa/openmct-demo/issues/9#issuecomment-710436117). We'll see.

___

In other news i also installed the GitHub CLI. It's awesome, and I did everything around this PR with it and Git bash. Very cool. I'm also extremely excited to start working with next.js and to see [my first conference](https://nextjs.org/conf/tickets/chrispinkney) in a few days. Although I may be big n00b and will likely have nothing of significance to contribute, I am nonetheless passionate and elated to move forward.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9fgx9z5882v66twvb0qj.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/38lyloyxrmzrsae7epnb.png)