translate-mutation-observer
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.4 • Public • Published

    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>

    Install

    npm i translate-mutation-observer

    DownloadsWeekly Downloads

    10

    Version

    1.1.4

    License

    MIT

    Unpacked Size

    41.9 kB

    Total Files

    33

    Last publish

    Collaborators

    • icelavender