A lightweight way to change words into other words.
| Key | Value |
Quick RegExp matching finds the words that need to be replaced inside of a div and does it quickly.
Word-pair library is stored in JSON format in mt-lib.js and is easy to edit both in advance and on-the-fly.
Works with any variation of uppercase and lowercase letters and will match them.
Ability to ignore a div and its children or monitor a div for any changes.
Makes it extremely easy to make your own translator - all you need is a language in JSON-format (or a little bit of creativity)!
The minified file is only 2kb in size - perfect for small web projects and quick additions to existing text interfaces.
Grab either minitranslate.js or minitranslate.min.js and include it (or a link to it on cdnjs) in your index.html along with your translations library (add the library first):
<script src="js/mt-lib.js"></script>
<script src="js/minitranslate.js"></script>
Edit mt-lib.json and add as many word-replacement pairs as you so desire, just make sure it stays in the same directory as minitranslate.
Simply add the class "mt-translate" to a div and watch as it is translated according to your library.
Add two <input> divs with IDs:
<input id="mt-input"/>
<input id="mt-output"/>
Whenever the input's content is changed, the output's will be the translation according to all word-pair matches in your library.