New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

translato

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

translato

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

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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:

npm install translato --save

Usage

Example

<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

Keywords

translation

FAQs

Package last updated on 16 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts