Translations

To localize the menu to an already available language, use the language configuration option.

<script>
    document.addEventListener(
        "DOMContentLoaded", () => {
            new Mmenu( "#menu", {
                // options
            }, {
                language: "nl"
            });
        }
    );
</script>

To find out what languages are already available, call the Mmenu static i18n method without any paramters, all translations will be logged to the console.

<script>
    console.log(Mmenu.i18n());
</script>

If you want, you can also type Mmenu.i18n() directly in the console.

Add a new translation

To translate the menu to a new language, first call the Mmenu static i18n method without any paramters, all translations will be logged to the console.

<script>
    console.log(Mmenu.i18n());
</script>

If you want, you can also type Mmenu.i18n() directly in the console.

Next, copy and paste the object for a single language into a variable and translate the sentences.

<script>
    const spanish = {
        'Menu': 'Menú',
        'Open submenu': 'Abrir submenú',
        'Close submenu': 'Cerrar submenú',
        // etc.
    };
</script>

Now pass the variable to the Mmenu static i18n method with the handle for the language as a second paramter. Make sure to do this before the menu is created.

<script>
    Mmenu.i18n(spanish, 'sp' );

    document.addEventListener(
        "DOMContentLoaded", () => {
            new Mmenu( "#menu", {
                // options
            }, {
                language: "sp"
            });
        }
    );

</script>