Translate HTML Page Into Different Languages – Translatorjs

Category: Javascript , Text | March 1, 2019
Author: EOussama
Views Total: 1,201 views
Official Page: Go to website
Last Update: March 1, 2019
License: MIT


Translate HTML Page Into Different Languages – Translatorjs


Yet another page translation library which can be used to translate the HTML page into any languages defined in a JSON dictionary.

How to use it:

Download and import the Translatorjs library.

<script src="/path/to/translate.min.js"></script>

Add the CSS class trnsjs to strings which will be translated into other languages.

<p class="trnsjs">Hello</p>
<p class="trnsjs">About</p>

Define the strings in different languages as follows:

const dictionary = {
      "About": {
        'fr': 'A propos',
        'es': 'nos'
      "Hello": {
        'fr': 'Bonjour',
        'es': 'Hola',

Initialize the Translatorjs library.

const translator = new Translator(dictionary);

Switch between languages.


You Might Be Interested In:

Leave a Reply