translate-mutation-observer
v1.1.4
Published
Translate page using mutation observer
Downloads
3
Maintainers
Readme
translate-mutation-observer
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>