DEV Community

Robert James Gabriel
Robert James Gabriel

Posted on • Updated on

Translate your browser extension in seconds

Hey 👋,

If your reading this you probably came for the same reason, I did in the past. How do I easily translate my browser extension to other languages?

Well as part of my startup Helperbird I needed to translate the browser extension to other languages to increase the reach. So I looked at different solutions and found one promising GitHub repo but it wasn't perfect.

With Chrome or Browser extensions, you have a folder layout like this.

_locales/{{languageCode}}/messages.json
Enter fullscreen mode Exit fullscreen mode

Where the original one by Thomas Brüggemann while great doesn't fit in into the browser extension development flow.

So I forked the extension and rewrote it, to make it for browser development (Also dont worry, I will be adding feature to the original master) . So if you're a browser extension developer. You can do the following now.

Installation

npm install -g translate-extension-json
Enter fullscreen mode Exit fullscreen mode

Usage

You need a Google Translate API Key.

translate-extension {{apiKey}} {{location of json file}} {{Translate from}  {{Tanslate too,Tanslate too,Tanslate too,}}
Enter fullscreen mode Exit fullscreen mode

e.g.

translate-extension-json iuOHAEbo9H788d34h93h4dioue2I locales en es,fr
Enter fullscreen mode Exit fullscreen mode

This would translate all strings in _locales/en/messages.json (relative to current folder in the shell) from English to Spanish and French, based on the Google Translate API language codes.

The target languages list is optional. When not present, it will be translated to all languages supported by Google Translate.

See it in action.

alt text

If you liked this project and guide, you can follow me here.

The node module code is here and the Github source is here

Top comments (0)