A simple javascript library for making basic HTML pages available in multiple languages.
Add this line to your HTML file
<script src="https://jarok.me/lib/translationEngine.js"></script>
You can download translationEngine.js and host it yourself. You will need to update it manually.
Add te-default="en"
to any element to make it translateable. Replace "en"
with the language code of the language that is writte inside the element tag.
To add translation, you can either add attributes like te-de
(DE -> German) or te-fr
(FR -> French), or the single attribute te-options="{'languageCode': 'text'}"
.
This will translate the text to "Hallo" when the language is set to "de" and "Bonjour" when the language is set to "fr". If the language is set to anything else, it will default to "Hello".
<p te-default="en" te-de="Hallo" te-fr="Bonjour">Hello</p>
This will translate the text to "Hallo" when the language is set to "de" and "Bonjour" when the language is set to "fr". If the language is set to anything else, it will default to "Hello".
<p te-default="en" te-options="{'de': 'Hallo', 'fr': 'Bonjour'}">Hello</p>
This will also work, although it is generally not recommended to mix the two methods.
<p te-default="en" te-de="Hallo" te-options="{'fr': 'Bonjour'}">Hello</p>