28 Jul 2017

In modern software development, we have a variety of tools, languages, platforms and devices as rich as it has never been before. If you are after a mobile solution it’s at least 3 operating systems to cover (iOS, Android and Windows 10 Mobile), for online experience you need to deal with a variety of browsers and screen sizes (Chrome, Firefox and IE). And last but not least — desktop apps that work on Windows, Linux and Apple computers. That is a lot!

There are many ways to solve this puzzle, but if you already have a web development team that knows JavaScript, HTML and CSS you are all set to start building native cross platform desktop apps. How? Electron is the framework to look at. 

We decided to experiment a bit and make our own app. The goal was not to make another “Hello world” sample, but to do something useful that could scratch an itch. How about a small translator app?

There are many translator apps available in the market. Most of the online translators require multi step actions to get the result. In most cases you have to manually run application, then enter the text, specify source as well as target language and press translate. For patient people only :)

With our small tool, you can make it a lot simpler. Here come the benefits of desktop app:

  • No need to start browser,
  • No need to navigate to any website,
  • No need to copy/paste text

App starts with the OS, just mark the text, copy to clipboard and press the hotkey. Translator app opens and your text is translated. Done!


It is responsive!

The beauty of Electron is not only that you can use your web dev skills to create cross platform desktop app, but also that it ‘inherits’ some of the goodies of the modern web development. It supports media queries so your desktop apps can be responsive as your website is! It’s not easy if you work with native desktop development languages.

We tested our app on Windows and Ubuntu and we are happy with the results.

Tech stack

On a high-level app was written using Electron, Angular and Bootstrap. To make our development more interesting we decided to use Electron Forge which is described as: "The command line interface for ambitious Electron applications". We are very ambitious, so we literally had no other choice :)

What's really awesome in Electron Forge is that it comes with the variety of templates:

  • Vanilla ES6/7,
  • React ,
  • React + TypeScript,
  • Angular 2,
  • Vue.JS 2.0,
  • Jade Templating

Just run some commands and you’re ready to go! We all don’t want to waste our time, do we?

We decided to use Angular 2 template because there was no template for Angular 4. Translations are done by Yandex translate API (free one). But if you are after a paid and higher quality translations you can easily make your own provider for Microsoft Translator Text API or Google Cloud Translation API. In addition, user can translate his/her text(s) in Bing Translator or Google Translate website from our app :)


Show me the code!

We are happy to make this project opensource and share it with you. It’s all free. Enjoy!

Feel free to clone its repository and run/play with the code - click here! 

You can also have a look at the presentation about Electron that we used on during tech event - just click here!


It’s cool and it’s easy to learn

It took just a week to make our app (with no prior experience with Electron). Have a look at the key benefits:

  • It’s cross platform (Windows, Linux, Mac),
  • It’s open source,
  • You can use your web skills (JavaScript, HTML and CSS),
  • Make a design for one browser only (Chromium) and it look the same on all platforms,
  • Your app integrates with operating system (hardware access, native dialogs, menus & notifications),
  • Can distribute with Windows and Mac App Store,
  • It’s in constant development and you can count on frequent releases


Still not convinced about Electron?

It’s not an early stage idea. It is mature and there are some serious products create with the framework. Just to mention a few:

  • Slack Desktop App,
  • Visual Studio Code,
  • Brave Browser,
  • Atom


When not to use Electron

Be careful when you are concerned with the size of the app, it’s heavy because contains Chromium inside. Might not be the fastest one to start up as well. As for compatibility, it will not work on Windows XP (if you care ;))


If above is not an issue you should definitely consider Electron for you next desktop app development.


Useful links:

https://electron.atom.io/

https://electronforge.io/

http://getbootstrap.com/

https://tech.yandex.com/translate/