1.1.4 • Published 3 years ago

translate-mutation-observer v1.1.4

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

translate-mutation-observer

test npm publish nycrc config on GitHub

Translate html page using mutation observer

Notes

This only work on certain type of DOM changes such as appendChild() search for MutationObserver for more info

Documentation

https://hoshiyuki-tamako.github.io/translate-mutation-observer/guide/

Install

npm i translate-mutation-observer

Usages

import { TranslateMutationObserver } from 'translate-mutation-observer';

// some translate function that take a full string and translate it
const t = (str: string) => str;
TranslateMutationObserver.n(t);

Without Observer

import { NodeTranslator } from 'translate-mutation-observer';

const t = (str: string) => str;
const translateMutationObserver = new NodeTranslator(t);
await translateMutationObserver.translate(document.documentElement);

Browser

<script type="module">
import { TranslateMutationObserver } from 'https://unpkg.com/translate-mutation-observer@^1/dist/index.js';
TranslateMutationObserver.n((str) => str.toLocaleLowerCase());
document.body.innerText = "TEST";
</script>
<body></body>
1.1.4

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago