To localize the menu,
include the desired translation .js file and use the language
configuration option.
<head> <script src="path/to/jquery.js"></script> <script src="path/to/jquery.mmenu.js"></script> <script src="path/to/jquery.mmenu.nl.js"></script> <script> $(document).ready(function() { $("#my-menu").mmenu({ // options }, { language: "nl" }); }); </script>
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/jquery.mmenu.[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/jquery.mmenu.fr.ts src/core/screenreader/translations/jquery.mmenu.fr.ts src/addons/searchfield/translations/jquery.mmenu.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.
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 and change the contents of an already available translation .ts file and paste it in a new file or as inline script.
<head> <script src="path/to/jquery.js"></script> <script src="path/to/jquery.mmenu.js"></script> <script src="path/to/jquery.mmenu.nl.js"></script> <script> (function( $ ) { var _PLUGIN_ = 'mmenu'; $[ _PLUGIN_ ].i18n({ 'Search': 'Doorzoek het menu' }); })( jQuery ); </script>
To get a list of all translatable texts, invoke the $.mmenu.i18n
function.
<script> console.log( $.mmenu.i18n() ); </script>