kaf.js sample 09
by mtsgi
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mtsgi/kitstrap/d/0.5/kitstrap.css">
<main id="kaf">
<h2 kit-i>{{ title }}</h2>
<input class="kit-textbox" kit:bind="lang" />
<a class="kit-button" kit-e="setLang">Set lang</a>
</main>
JavaScript
import Kaf from 'https://mtsgi.github.io/kafjs/kaf.js';
const kaf = new Kaf({
elem: '#kaf',
locale: 'en',
events: {
setLang() {
if (this._dictionary[this.lang]) {
this.__locale = this.lang;
}
else alert('Language not found!');
}
},
dictionary: {
en: { title: 'English' },
ja: { title: '日本語' },
zh: { title: '中文' }
}
});