@servicensw/translate

2.9.0-alpha.5 • Public • Published

@servicensw/translate

Translate component that will translate an entire website using Googles Website translator service.

translate component

Service NSW package documentation and examples
(Login credentials required)

Installation

npm install @servicensw/translate --save-dev

How to use

CSS

  • PostCSS workflow: @import '@servicensw/translate';
  • Sass/Eyeglass: @import 'servicensw-translate';
  • Native CSS: @import url('dist/translate.css');
  • Link tag: <link href="dist/translate.css" rel="stylesheet" type="text/css">

Vanilla JS

The recommended usage is of ES modules, to take advantage of code-splitting.

import Translate from "@servicensw/translate"

const translate = document.querySelectorAll(".translate:not(.is-excluded)")
translate.forEach((element, index) => {
  new Translate(element, index)
})

Legacy usage;

  • IIFE: <script src="dist/translate.js" type="text/javascript"></script> (initialized for all .translate elements)
  • Common JS: const Translate = require("@servicensw/translate") (initialize yourself)

HTML

<div class="translate"></div>

Change log

Dependents (0)

Package Sidebar

Install

npm i @servicensw/translate

Weekly Downloads

357

Version

2.9.0-alpha.5

License

MIT

Unpacked Size

46.4 kB

Total Files

12

Last publish

Collaborators

  • larowlan
  • rikki_iki
  • acbramley
  • erinsnsw
  • dojob65
  • ramya.shankaralingam
  • mariam.khoudier
  • christine.roque
  • previousnext-admin
  • mcaddz
  • jptaranto