Gogs 9ffe612f8d 2021-3-25 | há 3 anos atrás | |
---|---|---|
.. | ||
lang | há 3 anos atrás | |
.project | há 3 anos atrás | |
README.md | há 3 anos atrás | |
babel.js | há 3 anos atrás |
Javascript microframework for multilanguage purpose. It replaces strings from a json-language file to the innerHTML to the element with the id of the json key.
<script src="babel.js"></script>
babel.config({
lang: "en", // default language
dir: "lang", // the directory of the language files
extension: "json" // extension of the language files
})
babel.activate("en"); // loads and activates a language
Language files are simple JSON files:
{
heading: "Heading",
intro: "Introduction Text"
}
babel.activate()
with the default language is run on DOMContentLoaded.
babel.activate()
works as follows: For each key in the
json: document.getElementById(key).innerHTML = value