# translato

> Translato is a javascript library that helps to translate a html page into different languages with a previous defined JSON dictionary.

Latest version **1.0.0** (published 2018-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install translato
pnpm add translato
yarn add translato
bun add translato
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-16 |
| First published | 2018-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sascha Dobschal |
| Maintainers | klangsinn |
| Keywords | translation, language, international, dictionary, translate, wording |

## Links

- npm: https://www.npmjs.com/package/translato
- Repository: https://dobschal@github.com/dobschal/translato
- Homepage: https://github.com/dobschal/translato#readme
- Issues: https://github.com/dobschal/translato/issues
- npm.io page: https://npm.io/package/translato

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-05-16

## README

# Translato

Translato is a javascript library that helps to translate a html page into different languages with a previous defined JSON dictionary.

---

## Installation

Install via NodeJS and NPM:

```bash
npm install translato --save
```

## Usage

### Example

```html
<body>

    <h1 data-tl="start.headline"></h1>
    
    <div id="container"></div>

    <script src="translato.js"></script> 

    <script>

        translato.setDictionary({
            start: {
                headline: {
                    en: "Hello World",
                    de: "Hallo Welt"
                },
                content: {
                    en: "Here is awesome content.",
                    de: "Hier ist unglaublicher Inhalt."
                }
            }
        });

        translato.setLocale("en");
        
        let element = document.getElementById("container");

        element.innerHTML = translato.translateKeys("content");

    </script>
</body>
```

## API

* `translato.on({string} eventName, {function} callback)` - listen for events in translato
* `translato.translateKeys({strings} keys...)` - translate keys, returns an array if multiple keys are given
* `translato.translatePage()` - translate the whole page
* `translato.translateHTML({string} html)` - translate the given HTML string
* `translato.setLocale({string} languageKey, {boolean} translatePage?)` - language identifier, depends on dictionary
* `translato.setDictionary({object} dictionary)` - set the whole dictionary for the translations

## Events

* `translato.on("languageChanged", function)` - is fired when setLocale is executed

---
_Source: https://npm.io/package/translato · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
