-
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
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.
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". |
npm install eo-translatorjs
# or
pnpm add eo-translatorjs
# or
yarn add eo-translatorjs<script src="eo-translatorjs.min.js"></script>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.
Icon made by Freepik from Flaticon and is licensed by Creative Commons BY 3.0.