Basajs
a javascript library that allows your website to be multi-language with ease of use.
Installation
Add script in the <head>:
<script src="https://unpkg.com/basajs@latest/dist/basa.js"></script>
Use It
Basic
<p data-basa="hello"></p>
<p data-basa="greeting"></p>
<button onclick="Basa.changeLang('id')">id</button>
<button onclick="Basa.changeLang('en')">en</button>
<script>
const dict = {
hello: {
id: "halo",
en: "hello",
},
greeting: {
id: "selamat datang",
en: "welcome",
},
};
Basa.init({
languages: ["id", "en"],
useLocalStorage: true,
dictionary: dict,
});
</script>
Nested
const dict = {
hello: {
top: {
id: "halo",
en: "hello"
}
}
}
use it with
<p data-basa="hello.top"></p>
Default Settings
Basa.init({
languages: [],
useLocalStorage: false,
addActiveClass: false,
dictionary: {}
});