Translations introduction

To localize the menu, include the desired translation .js file and use the language configuration option.

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

Add a new translation

The best approach to add a translation, is to create a new translation .ts file for the core and each add-on that contains a translatable text.

First, copy one of the already available translation .ts files and rename it using the naming convention:

src/core/oncanvas/translations/[language].ts

Where [language] refers to the translation language, can be any word but preferred is a two digits language code in lowercase.

For example, a new translation in French would result in the following files:

src/core/oncanvas/translations/fr.ts
src/core/screenreader/translations/fr.ts
src/addons/searchfield/translations/fr.ts

Next, create a custom build and run $ gulp in the command-line.

If you're using Git, you might want to create a pull request for these changes.

Override translation

If you only want to override a part of an already available translation (or if you think the above method to create a new translation is to difficult), copy the contents of an already available translation .js file and paste it in a new file or as inline script.

<script>
    Mmenu.i18n({
        'Search': 'Doorzoek het menu'
    }, 'nl' );
</script>

To get a list of all translatable texts, invoke the $.mmenu.i18n function.

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