Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.
Oussama Essamadi edited this page Jun 12, 2026 · 9 revisions

EO TranslatorJS

Origin

What started as a quirky, fast, and slightly inefficient way to work out a translation solution for a static site evolved into a serious attempt to polish and publish a dependable tool for browser web content translation. As of the v3.0.0 release, a big influence of what makes EO TranslatorJS what it is was ngx-translate.

Use case

In most cases, all you need is a dictionary object and a function call.

Something that scares people away from using most other libraries is their unnecessary complexity — after all, we use libraries to avoid that excessive pain. EO TranslatorJS operates on very minimalistic controls. All you need to do is instantiate a translator object and set it for work.

const translator = new EOTranslator(dictionary, language);
dictionary (required) language (optional)
A plain object containing all translation keys grouped by language code. A string representing the default language. If omitted, the document's lang attribute is used; otherwise defaults to "en".

Installation

npm / pnpm / yarn

npm install eo-translatorjs
# or
pnpm add eo-translatorjs
# or
yarn add eo-translatorjs

Browser (script tag)

<script src="eo-translatorjs.min.js"></script>

Quick example

const dict = {
  en: { greeting: "Hello!" },
  fr: { greeting: "Bonjour!" },
  es: { greeting: "Hola!" },
};

const translator = new EOTranslator(dict, "en");

translator.translate("greeting");                    // → "Hello!"
translator.translate("greeting", { lang: "fr" });   // → "Bonjour!"

For the full API reference see the API Documentation wiki page.

Clone this wiki locally